Empty dataframe with a multi-index loses the type information about the index types #23842
Labels
Dtype Conversions
Unexpected or buggy dtype conversions
Duplicate Report
Duplicate issue or pull request
Indexing
Related to indexing on series/frames, not to indexes themselves
MultiIndex
Code Sample, a copy-pastable example if possible
Problem description
The columns of test2 all have the type float64
[('time', dtype('float64')), ('id', dtype('float64')), ('val', dtype('int64'))]
I am on pandas 0.23.0
The index should keep its types of [(Timestamp, object)]. When there's a single index, the types are preserved. Seems like a MultiIndex problem.
Expected Output
[('time', dtype('<M8[ns]')), ('id', dtype('O')), ('val', dtype('int64'))]
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.1.35-pv-ts2
machine: x86_64
processor:
byteorder: little
LC_ALL: en_US.utf8
LANG: en_US.utf8
LOCALE: en_US.UTF-8
pandas: 0.23.4
pytest: 3.8.0
pip: 10.0.1
setuptools: 40.2.0
Cython: 0.28.5
numpy: 1.13.3
scipy: 1.1.0
pyarrow: 0.8.0
xarray: None
IPython: 6.5.0
sphinx: 1.7.9
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 2.2.3
openpyxl: 2.5.6
xlrd: 1.1.0
xlwt: None
xlsxwriter: 1.1.0
lxml: None
bs4: 4.6.3
html5lib: 0.9999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: