BUG: idxmax returns incorrect dtype when index is timestamp and skipna is False · Issue #43587 · pandas-dev/pandas (original) (raw)
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of pandas.
- I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
import numpy as np import pandas as pd
s = pd.Series( [1., 2., np.nan], index=pd.DatetimeIndex(['NaT', '2015-02-08', 'NaT']) ) s.idxmin(skipna=False)
Issue Description
In the last few days something was merged that changed the dtype of idxmax
when skipna is False and the index is a datetime. I noticed this while running the upstream dask tests.
Expected Behavior
I would expect the dtype of idxmax
and idxmin
to match the dtype of the index (NaT
). Instead I get a nan with dtype float.
Compare the output above to
Installed Versions
INSTALLED VERSIONS ------------------ commit : 084c543python : 3.9.7.final.0 python-bits : 64 OS : Linux OS-release : 5.11.0-7633-generic Version : #35~1630100930~20.04~ae2753e-Ubuntu SMP Mon Aug 30 18:23:52 UTC machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8
pandas : 1.4.0.dev0+700.g084c543bf9
numpy : 1.22.0.dev0+1046.gb892ed2c7
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.0.4
Cython : None
pytest : 6.2.5
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.6.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.27.0
pandas_datareader: 0.10.0
bs4 : None
bottleneck : None
fsspec : 2021.08.1+8.g0589358
fastparquet : 0.7.1
gcsfs : None
matplotlib : 3.4.3
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 5.0.0
pyxlsb : None
s3fs : 2021.08.1+5.gf9d83b7
scipy : 1.7.1
sqlalchemy : 1.3.23
tables : 3.6.1
tabulate : None
xarray : 0.19.0
xlrd : None
xlwt : None
numba : 0.53.1