Skip to content

PERF: Deprecate casting of index of dates to DatetimeIndex #23598

Closed
@TomAugspurger

Description

@TomAugspurger
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypePerformanceMemory or execution speed performance

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions