diff --git a/doc/source/whatsnew/v2.0.0.rst b/doc/source/whatsnew/v2.0.0.rst index d49181238b6bc..281dd1feca522 100644 --- a/doc/source/whatsnew/v2.0.0.rst +++ b/doc/source/whatsnew/v2.0.0.rst @@ -145,6 +145,7 @@ Deprecations Removal of prior version deprecations/changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Disallow passing non-round floats to :class:`Timestamp` with ``unit="M"`` or ``unit="Y"`` (:issue:`47266`) +- Removed the ``numeric_only`` keyword from :meth:`Categorical.min` and :meth:`Categorical.max` in favor of ``skipna`` (:issue:`48821`) - Removed :func:`is_extension_type` in favor of :func:`is_extension_array_dtype` (:issue:`29457`) - Remove :meth:`DataFrameGroupBy.pad` and :meth:`DataFrameGroupBy.backfill` (:issue:`45076`) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index c69c8ae0d6bec..5a1d812cda53c 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -48,10 +48,7 @@ type_t, ) from pandas.compat.numpy import function as nv -from pandas.util._decorators import ( - deprecate_kwarg, - deprecate_nonkeyword_arguments, -) +from pandas.util._decorators import deprecate_nonkeyword_arguments from pandas.util._exceptions import find_stack_level from pandas.util._validators import validate_bool_kwarg @@ -2313,7 +2310,6 @@ def _reverse_indexer(self) -> dict[Hashable, npt.NDArray[np.intp]]: # ------------------------------------------------------------------ # Reductions - @deprecate_kwarg(old_arg_name="numeric_only", new_arg_name="skipna") def min(self, *, skipna: bool = True, **kwargs): """ The minimum value of the object. @@ -2350,7 +2346,6 @@ def min(self, *, skipna: bool = True, **kwargs): pointer = self._codes.min() return self._wrap_reduction_result(None, pointer) - @deprecate_kwarg(old_arg_name="numeric_only", new_arg_name="skipna") def max(self, *, skipna: bool = True, **kwargs): """ The maximum value of the object. diff --git a/pandas/tests/arrays/categorical/test_analytics.py b/pandas/tests/arrays/categorical/test_analytics.py index 1a8dbe25c0b75..39590bcc6636e 100644 --- a/pandas/tests/arrays/categorical/test_analytics.py +++ b/pandas/tests/arrays/categorical/test_analytics.py @@ -105,12 +105,12 @@ def test_min_max_only_nan(self, function, skipna): assert result is np.nan @pytest.mark.parametrize("method", ["min", "max"]) - def test_deprecate_numeric_only_min_max(self, method): + def test_numeric_only_min_max_raises(self, method): # GH 25303 cat = Categorical( [np.nan, 1, 2, np.nan], categories=[5, 4, 3, 2, 1], ordered=True ) - with tm.assert_produces_warning(expected_warning=FutureWarning): + with pytest.raises(TypeError, match=".* got an unexpected keyword"): getattr(cat, method)(numeric_only=True) @pytest.mark.parametrize("method", ["min", "max"])