Skip to content

Commit 3f8750e

Browse files
rhshadrachpmhatre1
authored andcommitted
CLN: Enforce deprecation of groupby.quantile supporting bool dtype (pandas-dev#57744)
1 parent f248fd0 commit 3f8750e

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ Removal of prior version deprecations/changes
205205
- In :meth:`DataFrame.stack`, the default value of ``future_stack`` is now ``True``; specifying ``False`` will raise a ``FutureWarning`` (:issue:`55448`)
206206
- Methods ``apply``, ``agg``, and ``transform`` will no longer replace NumPy functions (e.g. ``np.sum``) and built-in functions (e.g. ``min``) with the equivalent pandas implementation; use string aliases (e.g. ``"sum"`` and ``"min"``) if you desire to use the pandas implementation (:issue:`53974`)
207207
- Passing both ``freq`` and ``fill_value`` in :meth:`DataFrame.shift` and :meth:`Series.shift` and :meth:`.DataFrameGroupBy.shift` now raises a ``ValueError`` (:issue:`54818`)
208+
- Removed :meth:`.DataFrameGroupBy.quantile` and :meth:`.SeriesGroupBy.quantile` supporting bool dtype (:issue:`53975`)
208209
- Removed :meth:`DateOffset.is_anchored` and :meth:`offsets.Tick.is_anchored` (:issue:`56594`)
209210
- Removed ``DataFrame.applymap``, ``Styler.applymap`` and ``Styler.applymap_index`` (:issue:`52364`)
210211
- Removed ``DataFrame.bool`` and ``Series.bool`` (:issue:`51756`)

pandas/core/groupby/groupby.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -4279,16 +4279,8 @@ def pre_processor(vals: ArrayLike) -> tuple[np.ndarray, DtypeObj | None]:
42794279
elif is_bool_dtype(vals.dtype) and isinstance(vals, ExtensionArray):
42804280
out = vals.to_numpy(dtype=float, na_value=np.nan)
42814281
elif is_bool_dtype(vals.dtype):
4282-
# GH#51424 deprecate to match Series/DataFrame behavior
4283-
warnings.warn(
4284-
f"Allowing bool dtype in {type(self).__name__}.quantile is "
4285-
"deprecated and will raise in a future version, matching "
4286-
"the Series/DataFrame behavior. Cast to uint8 dtype before "
4287-
"calling quantile instead.",
4288-
FutureWarning,
4289-
stacklevel=find_stack_level(),
4290-
)
4291-
out = np.asarray(vals)
4282+
# GH#51424 remove to match Series/DataFrame behavior
4283+
raise TypeError("Cannot use quantile with bool dtype")
42924284
elif needs_i8_conversion(vals.dtype):
42934285
inference = vals.dtype
42944286
# In this case we need to delay the casting until after the

pandas/tests/groupby/test_numeric_only.py

+7-16
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,11 @@ def test_deprecate_numeric_only_series(dtype, groupby_func, request):
368368
msg = "cannot be performed against 'object' dtypes"
369369
else:
370370
msg = "is not supported for object dtype"
371-
warn = FutureWarning if groupby_func == "fillna" else None
372-
warn_msg = "DataFrameGroupBy.fillna is deprecated"
373-
with tm.assert_produces_warning(warn, match=warn_msg):
374-
with pytest.raises(TypeError, match=msg):
375-
method(*args)
371+
with pytest.raises(TypeError, match=msg):
372+
method(*args)
376373
elif dtype is object:
377-
warn = FutureWarning if groupby_func == "fillna" else None
378-
warn_msg = "SeriesGroupBy.fillna is deprecated"
379-
with tm.assert_produces_warning(warn, match=warn_msg):
380-
result = method(*args)
381-
with tm.assert_produces_warning(warn, match=warn_msg):
382-
expected = expected_method(*args)
374+
result = method(*args)
375+
expected = expected_method(*args)
383376
if groupby_func in obj_result:
384377
expected = expected.astype(object)
385378
tm.assert_series_equal(result, expected)
@@ -419,12 +412,10 @@ def test_deprecate_numeric_only_series(dtype, groupby_func, request):
419412
with pytest.raises(TypeError, match=msg):
420413
method(*args, numeric_only=True)
421414
elif dtype == bool and groupby_func == "quantile":
422-
msg = "Allowing bool dtype in SeriesGroupBy.quantile"
423-
with tm.assert_produces_warning(FutureWarning, match=msg):
415+
msg = "Cannot use quantile with bool dtype"
416+
with pytest.raises(TypeError, match=msg):
424417
# GH#51424
425-
result = method(*args, numeric_only=True)
426-
expected = method(*args, numeric_only=False)
427-
tm.assert_series_equal(result, expected)
418+
method(*args, numeric_only=False)
428419
else:
429420
result = method(*args, numeric_only=True)
430421
expected = method(*args, numeric_only=False)

0 commit comments

Comments
 (0)