@@ -2123,7 +2123,8 @@ def _reduce(self, name, axis=0, **kwargs):
2123
2123
raise TypeError (f"Categorical cannot perform the operation { name } " )
2124
2124
return func (** kwargs )
2125
2125
2126
- def min (self , numeric_only = None , ** kwargs ):
2126
+ @deprecate_kwarg (old_arg_name = "numeric_only" , new_arg_name = "skipna" )
2127
+ def min (self , skipna = True ):
2127
2128
"""
2128
2129
The minimum value of the object.
2129
2130
@@ -2139,17 +2140,18 @@ def min(self, numeric_only=None, **kwargs):
2139
2140
min : the minimum of this `Categorical`
2140
2141
"""
2141
2142
self .check_for_ordered ("min" )
2142
- if numeric_only :
2143
- good = self ._codes != - 1
2144
- pointer = self ._codes [good ].min (** kwargs )
2145
- else :
2146
- pointer = self ._codes .min (** kwargs )
2147
- if pointer == - 1 :
2148
- return np .nan
2143
+ good = self ._codes != - 1
2144
+ if not good .all ():
2145
+ if skipna :
2146
+ pointer = self ._codes [good ].min ()
2147
+ else :
2148
+ return np .nan
2149
2149
else :
2150
- return self .categories [pointer ]
2150
+ pointer = self ._codes .min ()
2151
+ return self .categories [pointer ]
2151
2152
2152
- def max (self , numeric_only = None , ** kwargs ):
2153
+ @deprecate_kwarg (old_arg_name = "numeric_only" , new_arg_name = "skipna" )
2154
+ def max (self , skipna = True ):
2153
2155
"""
2154
2156
The maximum value of the object.
2155
2157
@@ -2165,15 +2167,15 @@ def max(self, numeric_only=None, **kwargs):
2165
2167
max : the maximum of this `Categorical`
2166
2168
"""
2167
2169
self .check_for_ordered ("max" )
2168
- if numeric_only :
2169
- good = self ._codes != - 1
2170
- pointer = self ._codes [good ].max (** kwargs )
2171
- else :
2172
- pointer = self ._codes .max (** kwargs )
2173
- if pointer == - 1 :
2174
- return np .nan
2170
+ good = self ._codes != - 1
2171
+ if not good .all ():
2172
+ if skipna :
2173
+ pointer = self ._codes [good ].max ()
2174
+ else :
2175
+ return np .nan
2175
2176
else :
2176
- return self .categories [pointer ]
2177
+ pointer = self ._codes .max ()
2178
+ return self .categories [pointer ]
2177
2179
2178
2180
def mode (self , dropna = True ):
2179
2181
"""
0 commit comments