BUG: DataFrame.reset_index()
discards MultiIndex
dtypes if DataFrame
is empty
#35589
Closed
2 of 3 tasks
Labels
Bug
Duplicate Report
Duplicate issue or pull request
Needs Info
Clarification about behavior needed to assess issue
Code Sample, a copy-pastable example
Problem description
reset_index
shouldn't throw away dtype information in the special case where theDataFrame
has zero rows. Sometimes it's hard to avoid throwing away info when you manipulate zero-element DataFrames, but in this case there is no reason to do it.Expected Output
category and int64 dtypes from
reset_index
in all casesOutput of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.8.5.final.0
python-bits : 64
OS : Windows
OS-release : 10
machine : AMD64
processor : Intel64 Family 6 Model 63 Stepping 2, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United Kingdom.936
pandas : 1.0.5
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 49.2.0.post20200714
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.16.1
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : None
scipy : 1.5.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None
The text was updated successfully, but these errors were encountered: