Skip to content

Commit ab9f597

Browse files
author
Arno Veenstra
committed
Use skipna instead of numeric_only
1 parent 82e3278 commit ab9f597

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

pandas/core/arrays/categorical.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -2172,14 +2172,14 @@ def _reverse_indexer(self):
21722172
return result
21732173

21742174
# reduction ops #
2175-
def _reduce(self, name, axis=0, skipna=True, **kwargs):
2175+
def _reduce(self, name, axis=0, **kwargs):
21762176
func = getattr(self, name, None)
21772177
if func is None:
21782178
msg = 'Categorical cannot perform the operation {op}'
21792179
raise TypeError(msg.format(op=name))
21802180
return func(**kwargs)
21812181

2182-
def min(self, numeric_only=None, **kwargs):
2182+
def min(self, skipna=None, **kwargs):
21832183
"""
21842184
The minimum value of the object.
21852185
@@ -2195,7 +2195,7 @@ def min(self, numeric_only=None, **kwargs):
21952195
min : the minimum of this `Categorical`
21962196
"""
21972197
self.check_for_ordered('min')
2198-
if numeric_only:
2198+
if skipna:
21992199
good = self._codes != -1
22002200
pointer = self._codes[good].min(**kwargs)
22012201
else:
@@ -2205,7 +2205,7 @@ def min(self, numeric_only=None, **kwargs):
22052205
else:
22062206
return self.categories[pointer]
22072207

2208-
def max(self, numeric_only=None, **kwargs):
2208+
def max(self, skipna=None, **kwargs):
22092209
"""
22102210
The maximum value of the object.
22112211
@@ -2221,7 +2221,7 @@ def max(self, numeric_only=None, **kwargs):
22212221
max : the maximum of this `Categorical`
22222222
"""
22232223
self.check_for_ordered('max')
2224-
if numeric_only:
2224+
if skipna:
22252225
good = self._codes != -1
22262226
pointer = self._codes[good].max(**kwargs)
22272227
else:

pandas/core/series.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3676,8 +3676,7 @@ def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None,
36763676

36773677
# dispatch to ExtensionArray interface
36783678
if isinstance(delegate, ExtensionArray):
3679-
return delegate._reduce(name, skipna=skipna,
3680-
numeric_only=numeric_only, **kwds)
3679+
return delegate._reduce(name, skipna=skipna, **kwds)
36813680
elif is_datetime64_dtype(delegate):
36823681
# use DatetimeIndex implementation to handle skipna correctly
36833682
delegate = DatetimeIndex(delegate)

pandas/tests/series/test_analytics.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1498,10 +1498,10 @@ def test_drop_duplicates_categorical_bool(self, is_ordered):
14981498
sc.drop_duplicates(keep=False, inplace=True)
14991499
tm.assert_series_equal(sc, tc[~expected])
15001500

1501-
def test_min_numeric_only(self):
1501+
def test_min_skipna(self):
15021502
raw_cat = pd.Categorical(["a", "b", "c", "a"],
15031503
categories=["b", "c", "d"],
15041504
ordered=True)
15051505
s = pd.Series(raw_cat)
1506-
result = s.min(numeric_only=True)
1506+
result = s.min(skipna=True)
15071507
assert result == 'b'

0 commit comments

Comments
 (0)