Skip to content

Commit 4bfe686

Browse files
committed
Amend after 1st review
1 parent 9fab462 commit 4bfe686

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

doc/source/whatsnew/v0.25.1.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ For example, on MacOS installing Python with `pyenv` may lead to an incomplete P
1616

1717
.. _whatsnew_0251.bug_fixes:
1818

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

doc/source/whatsnew/v1.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ Deprecations
169169
- ``Index.set_value`` has been deprecated. For a given index ``idx``, array ``arr``,
170170
value in ``idx`` of ``idx_val`` and a new value of ``val``, ``idx.set_value(arr, idx_val, val)``
171171
is equivalent to ``arr[idx.get_loc(idx_val)] = val``, which should be used instead (:issue:`28621`).
172+
- The parameter ``numeric_only`` of :meth:`Categorical.min` and :meth:`Categorical.max` is deprecated and replaced with ``skipna`` (:issue:`25303`)
172173
-
173174

174175
.. _whatsnew_1000.prior_deprecations:

pandas/tests/arrays/categorical/test_analytics.py

Lines changed: 20 additions & 17 deletions
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)