Skip to content

BUG: Categorical constructor is not idempotent with datetime with tz #14190

Closed
@chris-b1

Description

@chris-b1

This isn't a huge deal, but popped up adding tests for #14173

Works fine with plain datetimes

In [9]: dti = pd.date_range('2014-01-01', '2014-01-05')

In [10]: pd.Categorical(pd.Categorical(dti))
Out[10]: 
[2014-01-01, 2014-01-02, 2014-01-03, 2014-01-04, 2014-01-05]
Categories (5, datetime64[ns]): [2014-01-01, 2014-01-02, 2014-01-03, 2014-01-04, 2014-01-05]

Does not with a tz

In [11]: dti = pd.date_range('2014-01-01', '2014-01-05', tz='US/Central')

In [12]: pd.Categorical(pd.Categorical(dti))
Out[12]: 
[NaT, NaT, NaT, NaT, NaT]
Categories (5, datetime64[ns, US/Central]): [2014-01-01 00:00:00-06:00, 2014-01-02 00:00:00-06:00, 2014-01-03 00:00:00-06:00, 2014-01-04 00:00:00-06:00, 2014-01-05 00:00:00-06:00]

Metadata

Metadata

Assignees

No one assigned

    Labels

    CategoricalCategorical Data TypeDtype ConversionsUnexpected or buggy dtype conversions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions