Skip to content

API: Should Index.min and max use nanmin and nanmax? #7261

Closed
@sinhrks

Description

@sinhrks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions