Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: Enforce deprecation of Categorical.min/max(numeric_only) #48821

Merged
merged 7 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down
7 changes: 1 addition & 6 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/arrays/categorical/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down