File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -1341,10 +1341,21 @@ def min(self, skipna=True):
1341
1341
1342
1342
def max (self , skipna = True ):
1343
1343
# TODO: skipna is broken with max.
1344
- result = nanops .nanmax (self .asi8 , skipna = skipna , mask = self .isna ())
1345
- if isna (result ):
1346
- # Period._from_ordinal does not handle np.nan gracefully
1344
+ # See https://github.com/pandas-dev/pandas/issues/24265
1345
+ mask = self .isna ()
1346
+ if skipna :
1347
+ values = self [~ mask ].asi8
1348
+ elif mask .any ():
1349
+ return NaT
1350
+ else :
1351
+ values = self .asi8
1352
+
1353
+ if not len (values ):
1354
+ # short-circut for empty max / min
1347
1355
return NaT
1356
+ # Do not pass mask, since it's maybe not the right shape.
1357
+ result = nanops .nanmax (values , skipna = skipna )
1358
+ # Don't have to worry about NA `result`, since no NA went in.
1348
1359
return self ._box_func (result )
1349
1360
1350
1361
You can’t perform that action at this time.
0 commit comments