API: Should Index.min and max use nanmin and nanmax? (original) (raw)
Index and Series min and max handles nan and NaT differently. Even though min and max are defined in IndexOpsMixin, Series doesn't use them and use NDFrame definitions.
pd.Index([np.nan, 1.0]).min()
# nan
pd.Index([np.nan, 1.0]).max()
# nan
pd.DatetimeIndex([pd.NaT, '2011-01-01']).min()
# NaT
pd.DatetimeIndex([pd.NaT, '2011-01-01']).max()
#2011-01-01 00:00:00
# Series excludes nan and NaT
pd.Series([np.nan, 1.0]).min()
#1.0
pd.Series([np.nan, 1.0]).max()
#1.0
pd.Series([pd.NaT, pd.Timestamp('2011-01-01')]).min()
#2011-01-01 00:00:00
pd.Series([pd.NaT, pd.Timestamp('2011-01-01')]).max()
#2011-01-01 00:00:00