Skip to content

Commit

Permalink
suggested change
Browse files Browse the repository at this point in the history
  • Loading branch information
debnathshoham committed Sep 9, 2021
1 parent 17b373d commit a55b74b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2440,7 +2440,7 @@ def pre_processor(vals: ArrayLike) -> tuple[np.ndarray, np.dtype | None]:
inference = np.dtype("timedelta64[ns]")
out = np.asarray(vals).astype(float)
elif isinstance(vals, ExtensionArray) and is_float_dtype(vals):
inference = np.dtype(object)
inference = np.dtype(np.float64)
out = vals.to_numpy(dtype=float, na_value=np.nan)
else:
out = np.asarray(vals)
Expand Down
14 changes: 7 additions & 7 deletions pandas/tests/groupby/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,15 @@ def test_groupby_quantile_NA_float(any_float_allowed_nullable_dtype):
{"x": [1, 1], "y": [0.2, np.nan]}, dtype=any_float_allowed_nullable_dtype
)
result = df.groupby("x")["y"].quantile(0.5)
expected = pd.Series([0.2], dtype=float, index=[1.0], name="y")
expected.index.name = "x"
expected = pd.Series([0.2], dtype=float, index=Index(df["x"][:1]), name="y")
tm.assert_series_equal(expected, result)

result = df.groupby("x")["y"].quantile([0.5, 0.75])
expected = pd.Series(
[0.2] * 2,
index=pd.MultiIndex.from_product(([1.0], [0.5, 0.75]), names=["x", None]),
index=pd.MultiIndex.from_arrays(
[Index(df["x"]), [0.5, 0.75]], names=["x", None]
),
name="y",
)
tm.assert_series_equal(result, expected)
Expand All @@ -271,11 +272,11 @@ def test_groupby_quantile_NA_int(any_nullable_int_dtype):
# GH#42849
df = DataFrame({"x": [1, 1], "y": [2, 5]}, dtype=any_nullable_int_dtype)
result = df.groupby("x")["y"].quantile(0.5)
expected = pd.Series([3.5], dtype=float, index=Index([1], name="x"), name="y")
expected = pd.Series([3.5], dtype=float, index=Index(df["x"][:1]), name="y")
tm.assert_series_equal(expected, result)

result = df.groupby("x").quantile(0.5)
expected = DataFrame({"y": 3.5}, index=Index([1], name="x"))
expected = DataFrame({"y": 3.5}, index=Index(df["x"][:1]))
tm.assert_frame_equal(result, expected)


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


Expand Down

0 comments on commit a55b74b

Please sign in to comment.