Skip to content

Commit a55b74b

Browse files
committed
suggested change
1 parent 17b373d commit a55b74b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pandas/core/groupby/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,7 @@ def pre_processor(vals: ArrayLike) -> tuple[np.ndarray, np.dtype | None]:
24402440
inference = np.dtype("timedelta64[ns]")
24412441
out = np.asarray(vals).astype(float)
24422442
elif isinstance(vals, ExtensionArray) and is_float_dtype(vals):
2443-
inference = np.dtype(object)
2443+
inference = np.dtype(np.float64)
24442444
out = vals.to_numpy(dtype=float, na_value=np.nan)
24452445
else:
24462446
out = np.asarray(vals)

pandas/tests/groupby/test_quantile.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,15 @@ def test_groupby_quantile_NA_float(any_float_allowed_nullable_dtype):
254254
{"x": [1, 1], "y": [0.2, np.nan]}, dtype=any_float_allowed_nullable_dtype
255255
)
256256
result = df.groupby("x")["y"].quantile(0.5)
257-
expected = pd.Series([0.2], dtype=float, index=[1.0], name="y")
258-
expected.index.name = "x"
257+
expected = pd.Series([0.2], dtype=float, index=Index(df["x"][:1]), name="y")
259258
tm.assert_series_equal(expected, result)
260259

261260
result = df.groupby("x")["y"].quantile([0.5, 0.75])
262261
expected = pd.Series(
263262
[0.2] * 2,
264-
index=pd.MultiIndex.from_product(([1.0], [0.5, 0.75]), names=["x", None]),
263+
index=pd.MultiIndex.from_arrays(
264+
[Index(df["x"]), [0.5, 0.75]], names=["x", None]
265+
),
265266
name="y",
266267
)
267268
tm.assert_series_equal(result, expected)
@@ -271,11 +272,11 @@ def test_groupby_quantile_NA_int(any_nullable_int_dtype):
271272
# GH#42849
272273
df = DataFrame({"x": [1, 1], "y": [2, 5]}, dtype=any_nullable_int_dtype)
273274
result = df.groupby("x")["y"].quantile(0.5)
274-
expected = pd.Series([3.5], dtype=float, index=Index([1], name="x"), name="y")
275+
expected = pd.Series([3.5], dtype=float, index=Index(df["x"][:1]), name="y")
275276
tm.assert_series_equal(expected, result)
276277

277278
result = df.groupby("x").quantile(0.5)
278-
expected = DataFrame({"y": 3.5}, index=Index([1], name="x"))
279+
expected = DataFrame({"y": 3.5}, index=Index(df["x"][:1]))
279280
tm.assert_frame_equal(result, expected)
280281

281282

@@ -284,8 +285,7 @@ def test_groupby_quantile_allNA_column(dtype):
284285
# GH#42849
285286
df = DataFrame({"x": [1, 1], "y": [pd.NA] * 2}, dtype=dtype)
286287
result = df.groupby("x")["y"].quantile(0.5)
287-
expected = pd.Series([np.nan], dtype=float, index=[1.0], name="y")
288-
expected.index.name = "x"
288+
expected = pd.Series([np.nan], dtype=float, index=Index(df["x"][:1]), name="y")
289289
tm.assert_series_equal(expected, result)
290290

291291

0 commit comments

Comments
 (0)