Skip to content

Regression: DatetimeIndex ignores timezones #11736

Closed
@hcarvalhoalves

Description

@hcarvalhoalves

In 0.16.2, DatetimeIndex functions used to handle the timezone correctly:

In [1]: import pandas as pd
In [2]: df = pd.DataFrame({'x': ["2015-05-27 19:05:17.178000-02:00"]})
In [3]: pd.DatetimeIndex(df.x)
Out[3]: DatetimeIndex(['2015-05-27 19:05:17.178000-02:00'], dtype='datetime64[ns]', freq=None, tz='tzoffset(None, -7200)')

In 0.17.0, it's now ignoring timezones:

In [1]: import pandas as pd

In [2]: df = pd.DataFrame({'x': ["2015-05-27 19:05:17.178000-02:00"]})

In [3]: pd.DatetimeIndex(df.x)
Out[3]: DatetimeIndex(['2015-05-27 21:05:17.178000'], dtype='datetime64[ns]', freq=None)

This slipped thru since the tests are very simple and don't cover many cases:

https://github.com/pydata/pandas/blob/cda9da82a68aed42421f7f788fb0c1e949e7a60c/pandas/tests/test_format.py#L3342

I'll attempt a patch later but if someone can give pointers where the breaking change happened I appreciate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions