Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
In [1]: import pandas as pd
In [2]: pd.__version__
Out[2]: '1.1.0.dev0+1967.gf5b2e5a9a'
In [3]: expected_column_index = pd.MultiIndex.from_tuples(
...: [(pd.to_datetime("02/29/2020"), pd.to_datetime("03/01/2020"))],
...: names=[
...: 'a', 'b'])
In [4]: pd.DataFrame([], columns=expected_column_index)
---------------------------------------------------------------------------
InvalidIndexError
Problem description
This works in 1.0.5, but not in master.
See discussion in #34748 . This new issue should be resolved before that PR moves forward.
Expected Output
In [1]: import pandas as pd
In [2]: pd.__version__
Out[2]: '1.0.5'
In [3]: expected_column_index = pd.MultiIndex.from_tuples(
...: [(pd.to_datetime("02/29/2020"), pd.to_datetime("03/01/2020"))],
...: names=[
...: 'a', 'b'])
In [4]: pd.DataFrame([], columns=expected_column_index)
Out[4]:
Empty DataFrame
Columns: [(2020-02-29 00:00:00, 2020-03-01 00:00:00)]
Index: []
Output of pd.show_versions()
pandas : 1.1.0.dev0+1967.gf5b2e5a9a
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 42.0.2.post20191201
Cython : 0.29.20
pytest : 5.4.3
hypothesis : 5.18.0
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : 1.2.9
lxml.etree : 4.5.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.15.0
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : 0.7.4
fastparquet : 0.4.0
gcsfs : None
matplotlib : 3.1.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : 0.15.1
pytables : None
pyxlsb : 1.0.6
s3fs : 0.4.2
scipy : 1.3.1
sqlalchemy : 1.3.17
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.15.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.46.0