Skip to content

Commit 5fb0ab3

Browse files
committed
Amend after 1st review
1 parent 79472d8 commit 5fb0ab3

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

doc/source/whatsnew/v0.25.1.rst

-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ Other enhancements
1818

1919
.. _whatsnew_0251.bug_fixes:
2020

21-
Other deprecations
22-
^^^^^^^^^^^^^^^^^^
23-
24-
- The parameter ``numeric_only`` of :meth:`Categorical.min` and :meth:`Categorical.max` is deprecated and replaced with ``skipna`` (:issue:`25303`)
25-
2621
Bug fixes
2722
~~~~~~~~~
2823

doc/source/whatsnew/v1.0.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Other API changes
5454
Deprecations
5555
~~~~~~~~~~~~
5656

57-
-
57+
- The parameter ``numeric_only`` of :meth:`Categorical.min` and :meth:`Categorical.max` is deprecated and replaced with ``skipna`` (:issue:`25303`)
5858
-
5959

6060
.. _whatsnew_1000.prior_deprecations:

pandas/tests/arrays/categorical/test_analytics.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,34 @@ def test_min_max(self):
3535
assert _min == "d"
3636
assert _max == "a"
3737

38+
@pytest.mark.parametrize("skipna", [True, False])
39+
def test_min_max_with_nan(self, skipna):
40+
# GH 25303
3841
cat = Categorical(
3942
[np.nan, "b", "c", np.nan], categories=["d", "c", "b", "a"], ordered=True
4043
)
41-
_min = cat.min(skipna=False)
42-
_max = cat.max(skipna=False)
43-
assert np.isnan(_min)
44-
assert np.isnan(_max)
44+
_min = cat.min(skipna=skipna)
45+
_max = cat.max(skipna=skipna)
4546

46-
_min = cat.min()
47-
assert _min == "c"
48-
_max = cat.max()
49-
assert _max == "b"
47+
if skipna is False:
48+
assert np.isnan(_min)
49+
assert np.isnan(_max)
50+
else:
51+
assert _min == "c"
52+
assert _max == "b"
5053

5154
cat = Categorical(
5255
[np.nan, 1, 2, np.nan], categories=[5, 4, 3, 2, 1], ordered=True
5356
)
54-
_min = cat.min(skipna=False)
55-
_max = cat.max(skipna=False)
56-
assert np.isnan(_min)
57-
assert np.isnan(_max)
58-
59-
_min = cat.min()
60-
assert _min == 2
61-
_max = cat.max()
62-
assert _max == 1
57+
_min = cat.min(skipna=skipna)
58+
_max = cat.max(skipna=skipna)
59+
60+
if skipna is False:
61+
assert np.isnan(_min)
62+
assert np.isnan(_max)
63+
else:
64+
assert _min == 2
65+
assert _max == 1
6366

6467
@pytest.mark.parametrize("method", ["min", "max"])
6568
def test_deprecate_numeric_only_min_max(self, method):

0 commit comments

Comments
 (0)