BUG: Categorical constructor is not idempotent with datetime with tz · Issue #14190 · pandas-dev/pandas (original) (raw)

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]