Skip to content

Creating Series from DatetimeIndex w/ tz loses tz info #6032

@cancan101

Description

@cancan101

The original DatetimeIndex has the tz:

In [1]: pd.DatetimeIndex(
   ...:     pd.tseries.tools.to_datetime(['2013-1-1 13:00'], errors="raise")).tz_localize('US/Pacific')[0]
Out[1]: Timestamp('2013-01-01 13:00:00-0800', tz='US/Pacific')

But when converted to a Series, the tz info is lost:

In [2]: pd.Series(pd.DatetimeIndex(
   ...:     pd.tseries.tools.to_datetime(['2013-1-1 13:00'], errors="raise")).tz_localize('US/Pacific'))[0]
Out[2]: Timestamp('2013-01-01 21:00:00', tz=None)

If this is by design, then a warning would be nice.

This issue came up when I tried to add a list of timezone aware dates to a DataFrame.

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