Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sinhrks opened this issue May 28, 2014 · 1 comment · Fixed by #7279
Closed

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

sinhrks opened this issue May 28, 2014 · 1 comment · Fixed by #7279
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@sinhrks
Copy link
Member

sinhrks commented May 28, 2014

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
@jreback
Copy link
Contributor

jreback commented May 28, 2014

yah that is right; these are actually overriden in core/generic.py for Series; so these can/should directly use nanmin/max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants