PERF: Deprecate casting of index of dates to DatetimeIndex · Issue #23598 · pandas-dev/pandas (original) (raw)
In [5]: index = pd.Index([pd.Timestamp('2001'), pd.Timestamp('2002')], dtype=object)
In [6]: pd.Series(1, index=index).index Out[6]: DatetimeIndex(['2001-01-01', '2002-01-01'], dtype='datetime64[ns]', freq=None)
This was the root cause of #23591. Why are we doing that?
Note that this doesn't affect the case of index=[pd.Timestamp(...), pd.Timestamp(...)]
, as that would have previously been converted to a DatetimeIndex. It seems be only when you have an Index of datetimes.
I'm going through our test cases that hit this now.