Skip to content
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

Series.idxmax() and Series.max() show inconsistent behaviour with pd.np.Inf #13880

Closed
nescio007 opened this issue Aug 2, 2016 · 1 comment
Closed
Labels
Bug Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves Numeric Operations Arithmetic, Comparison, and Logical operations

Comments

@nescio007
Copy link

idxmax is supposed to return the index of the maximum element. However, it seems to ignore special values like infinity (pd.np.Inf), leading to the following inconsistency:

>>> from pandas import DataFrame
>>> s = pd.Series([0,5,pd.np.Inf])
>>> s.max() == s.ix[s.idxmax()]

This snippet will return False, since s.idxmax() will return 1, the index of value 5, while s.max() returns Inf as expected.

Expected Output

True

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Linux
OS-release: 4.6.4-1-ARCH
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: de_DE.UTF-8

pandas: 0.18.1
nose: 1.3.6
pip: 8.1.2
setuptools: 25.1.0
Cython: None
numpy: 1.11.1
scipy: 0.14.0
statsmodels: 0.6.1
xarray: None
IPython: 5.0.0
sphinx: None
patsy: 0.4.1
dateutil: 2.4.2
pytz: 2015.2
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.4.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None
@nescio007 nescio007 changed the title Series.idxmax() and Series.max() show inconsitent behaviour with pd.np.Inf Series.idxmax() and Series.max() show inconsistent behaviour with pd.np.Inf Aug 2, 2016
@jreback
Copy link
Contributor

jreback commented Aug 2, 2016

this is a dupe of #13595

@jreback jreback closed this as completed Aug 2, 2016
@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Duplicate Report Duplicate issue or pull request Numeric Operations Arithmetic, Comparison, and Logical operations labels Aug 2, 2016
@jreback jreback added this to the No action milestone Aug 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

No branches or pull requests

2 participants