Skip to content

BUG/API: Categorical doesn't support categories with tz #10713

Closed
@sinhrks

Description

@sinhrks

Creating Categorical from DatetimeIndex with tz results in GMT.

import pandas as pd
idx = pd.date_range('2011-01-01', periods=5, freq='M', tz='US/Eastern')
idx
# DatetimeIndex(['2011-01-31 00:00:00-05:00', '2011-02-28 00:00:00-05:00',
#                '2011-03-31 00:00:00-04:00', '2011-04-30 00:00:00-04:00',
#                '2011-05-31 00:00:00-04:00'],
#               dtype='datetime64[ns]', freq='M', tz='US/Eastern')

pd.Categorical(idx)
# [2011-01-31 05:00:00, 2011-02-28 05:00:00, 2011-03-31 04:00:00, 2011-04-30 04:00:00, 2011-05-31 # 04:00:00]
# Categories (5, datetime64[ns]): [2011-01-31 05:00:00, 2011-02-28 05:00:00, 2011-03-31 04:00:00
#                                 , 2011-04-30 04:00:00, 2011-05-31 04:00:00]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions