-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DataFrame.idxmax returns NaN if all entries are NaN, contradicts idxmax documentation #18206
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
Comments
the result is correct, its the documentation that is wrong. If you have an all NaN column we have no choice but to return NaN. |
ok thanks @jreback for clarifying, I guessed so since series' |
@ghasemnaddaf if you'd like to do a PR to clarify in the docs? (in Series as well) would be great. |
Given that you typically use the result of idxmax for indexing, I am not sure the NaN behaviour is necessarily that much better than 0 |
Funny thing is that the
and given this behaviour has always been like this, I am fine with keeping it like this to be clear. I was just wondering the reason for 0. And you can always use |
(cherry picked from commit 63e8527)
Code Sample, a copy-pastable example if possible
Problem description
According to DataFrame.idxmax documentation:
If an entire row/column is NA, the result will be first index
Expected Output
Output of
pd.show_versions()
commit: None
python: 3.4.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-4-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_CA.utf8
LOCALE: en_CA.UTF-8
pandas: 0.20.2
pytest: 2.9.1
pip: 9.0.1
setuptools: 36.2.7
Cython: None
numpy: 1.13.0
scipy: 0.19.0
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0b10
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: