不再可能用日期索引 pandas DatetimeIndex?

No longer possible to index a pandas DatetimeIndex with a date?

我刚刚从 0.24 升级到 pandas 1.1,我觉得我失去了理智。真的不能再用日期索引 DatetimeIndex 吗?

#This now fails!
import datetime as dt
s = pd.Series([1,2], pd.DatetimeIndex([dt.date(2020,1,1),dt.date(2020,1,2)]))
s.loc[dt.date(2020,1,2)]
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-49-18ac6239cd3a> in <module>
      1 s = pd.Series([1,2], pd.DatetimeIndex([dt.date(2020,1,1),dt.date(2020,1,2)]))
----> 2 s.loc[dt.date(2020,1,2)]
....

请告诉我我错了!

这是一个将在 1.1.1 中修复的错误

https://github.com/pandas-dev/pandas/issues/35466