Skip to content

DatetimeIndex.to_frame() inconsistent with dti.to_series().to_frame() #23728

Closed
@jbrockmendel

Description

@jbrockmendel

For TZ-aware DatetimeIndex, to_series() drops the timezone unless we pass keep_tz=True

>>> dti = pd.date_range('1977-04-15', periods=3, freq='MS', tz='US/Hawaii')

>>> dti.to_series().to_frame().dtypes
0    datetime64[ns]

>>> dti.to_frame().dtypes
0    datetime64[ns, US/Hawaii]

IIRC there has been discussion about deprecating the need for keep_tz; this should be another reason to do so.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions