Pandas version checks

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of pandas.

  • [ ] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

from datetime import date
import pandas as pd

mi_a = pd.MultiIndex.from_tuples([(date(2001, 1, 1), "foo")], names=["first", "second"])
mi_b = pd.MultiIndex.from_tuples([(pd.Timestamp(date(2001, 1, 1)), "asdf")], names=["first", "second"])

mi_a.union(mi_b)

Issue Description

The following exception is thrown:

InvalidIndexError                         Traceback (most recent call last)
...

InvalidIndexError: Reindexing only valid with uniquely valued Index objects

Expected Behavior

I would have expected the two values date(2001, 1, 1) and pd.Timestamp(date(2001, 1, 1)) to be treated as different values, which is how I believe pd.DataFrame.drop_duplicates acts. However treating the two values as identical could also be valid, but I don't think that the exception is.

Installed Versions

INSTALLED VERSIONS ------------------ commit : c888af6d0bb674932007623c0867e1fbd4bdc2c6 python : 3.13.5 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19045 machine : AMD64 processor : Intel64 Family 6 Model 158 Stepping 13, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : English_United Kingdom.1252 pandas : 2.3.1 numpy : 2.3.1 pytz : 2025.2 dateutil : 2.9.0.post0 pip : 25.0 Cython : None sphinx : None IPython : 8.37.0 adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.13.4 blosc : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None html5lib : None hypothesis : None gcsfs : None jinja2 : 3.1.6 lxml.etree : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None psycopg2 : None pymysql : None pyarrow : None pyreadstat : None pytest : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlsxwriter : None zstandard : None tzdata : 2025.2 qtpy : None pyqt5 : None

Comment From: jwg4

This apparent bug also affects another basic operation which could be expected to succeed, DataFrame.combine_first when using frames with MultiIndex as described above:

from datetime import date
import pandas as pd

df_a = pd.DataFrame(
    [
        (date(2001, 1, 1), "foo", 11),
    ],
    columns=["a", "b", "c"]
)
df_a = df_a.set_index(["a", "b"])

df_b = pd.DataFrame(
    [
        (pd.Timestamp(date(2001, 1, 1)), "bar", 33),
    ],
    columns=["a", "b", "c"]
)
df_b = df_b.set_index(["a", "b"])

df_a.combine_first(df_b)

Comment From: rhshadrach

Thanks for the report. pandas is converting the Index to a DatetimeIndex here:

https://github.com/pandas-dev/pandas/blob/7c2796d134e74f613cbfd85137d6809f5abf39a4/pandas/core/indexes/base.py#L6217-L6221

Further investigations are welcome!