Skip to content

Commit 0ecd0ec

Browse files
authored
DEPR: Enforce deprecation of Categorical.min/max(numeric_only) (#48821)
1 parent 14b2b61 commit 0ecd0ec

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

doc/source/whatsnew/v2.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ Removal of prior version deprecations/changes
146146
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147147
- Remove arguments ``names`` and ``dtype`` from :meth:`Index.copy` and ``levels`` and ``codes`` from :meth:`MultiIndex.copy` (:issue:`35853`, :issue:`36685`)
148148
- Disallow passing non-round floats to :class:`Timestamp` with ``unit="M"`` or ``unit="Y"`` (:issue:`47266`)
149+
- Removed the ``numeric_only`` keyword from :meth:`Categorical.min` and :meth:`Categorical.max` in favor of ``skipna`` (:issue:`48821`)
149150
- Removed :func:`is_extension_type` in favor of :func:`is_extension_array_dtype` (:issue:`29457`)
150151
- Remove :meth:`DataFrameGroupBy.pad` and :meth:`DataFrameGroupBy.backfill` (:issue:`45076`)
151152
- Enforced :meth:`Rolling.count` with ``min_periods=None`` to default to the size of the window (:issue:`31302`)

pandas/core/arrays/categorical.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@
4848
type_t,
4949
)
5050
from pandas.compat.numpy import function as nv
51-
from pandas.util._decorators import (
52-
deprecate_kwarg,
53-
deprecate_nonkeyword_arguments,
54-
)
51+
from pandas.util._decorators import deprecate_nonkeyword_arguments
5552
from pandas.util._exceptions import find_stack_level
5653
from pandas.util._validators import validate_bool_kwarg
5754

@@ -2313,7 +2310,6 @@ def _reverse_indexer(self) -> dict[Hashable, npt.NDArray[np.intp]]:
23132310
# ------------------------------------------------------------------
23142311
# Reductions
23152312

2316-
@deprecate_kwarg(old_arg_name="numeric_only", new_arg_name="skipna")
23172313
def min(self, *, skipna: bool = True, **kwargs):
23182314
"""
23192315
The minimum value of the object.
@@ -2350,7 +2346,6 @@ def min(self, *, skipna: bool = True, **kwargs):
23502346
pointer = self._codes.min()
23512347
return self._wrap_reduction_result(None, pointer)
23522348

2353-
@deprecate_kwarg(old_arg_name="numeric_only", new_arg_name="skipna")
23542349
def max(self, *, skipna: bool = True, **kwargs):
23552350
"""
23562351
The maximum value of the object.

pandas/tests/arrays/categorical/test_analytics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ def test_min_max_only_nan(self, function, skipna):
105105
assert result is np.nan
106106

107107
@pytest.mark.parametrize("method", ["min", "max"])
108-
def test_deprecate_numeric_only_min_max(self, method):
108+
def test_numeric_only_min_max_raises(self, method):
109109
# GH 25303
110110
cat = Categorical(
111111
[np.nan, 1, 2, np.nan], categories=[5, 4, 3, 2, 1], ordered=True
112112
)
113-
with tm.assert_produces_warning(expected_warning=FutureWarning):
113+
with pytest.raises(TypeError, match=".* got an unexpected keyword"):
114114
getattr(cat, method)(numeric_only=True)
115115

116116
@pytest.mark.parametrize("method", ["min", "max"])

0 commit comments

Comments
 (0)