BUG: Lookup by datetime in timestamp index does not work #58815
Labels
Bug
datetime.date
stdlib datetime.date support
Datetime
Datetime data dtype
Duplicate Report
Duplicate issue or pull request
Index
Related to the Index class or subclasses
Pandas version checks
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 main branch of pandas.
Reproducible Example
Issue Description
As discussed, for consistency, whenever an implicit cast to
Timestamp
is done,datetime.date
should be acceptable along withstr
anddatetime.datetime
.In the example above,
df0
only accepts adatetime.date
(which is fine),while
df1
accepts a few "timestamp designators" (pd.Timestamp
,str
,datetime.datetime
) but notdatetime.date
which seems inconsistent.Expected Behavior
df1.loc[d0]
should work alongside withdf1.loc[pd.Timestamp(d0)]
.df1.loc[str(d0)]
, anddf1.loc[datetime.datetime.combine(d0,datetime.time.min)]
.Installed Versions
INSTALLED VERSIONS
commit : d9cdd2e
python : 3.12.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 85 Stepping 7, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : English_United States.1252
pandas : 2.2.2
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.8.2
setuptools : 69.5.1
pip : 24.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 5.2.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.24.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : 2024.5.0
gcsfs : None
matplotlib : 3.8.4
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 15.0.0
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : 1.13.0
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : 2.4.1
pyqt5 : None
The text was updated successfully, but these errors were encountered: