Skip to content

DataFrame.idxmax returns NaN if all entries are NaN, contradicts idxmax documentation #18206

Closed
@ghasemnaddaf

Description

@ghasemnaddaf

Code Sample, a copy-pastable example if possible

(Pdb) df = pd.DataFrame({'a': [pd.np.nan]*10})
(Pdb) df.idxmax()
a   NaN
dtype: float64
(Pdb) df.idxmax(skipna=True)
a   NaN
dtype: float64
(Pdb) pd.__version__
'0.20.2'

Problem description

According to DataFrame.idxmax documentation: If an entire row/column is NA, the result will be first index

Expected Output

df.idxmax(skipna=True)
a     0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions