Skip to content

DatetimeIndex + TimeDelta gives wrong results when timezone is set #13905

Closed
@jzwinck

Description

@jzwinck

When I add a time delta to a DatetimeIndex which is tz-aware, the results appear as UTC, but sometimes claim to be in the original non-UTC timezone.

Code

import pandas as pd
index = pd.DatetimeIndex(['2016-06-28 05:30', '2016-06-28 05:31'], dtype='datetime64[ns, America/Chicago]')
offset = pd.Series(['00:00:05', '00:00:05'], dtype='timedelta64[ns]', index=index)
print(index + offset)
print(index + offset.values)

Actual Output

2016-06-28 05:30:00-05:00   2016-06-28 10:30:05
2016-06-28 05:31:00-05:00   2016-06-28 10:31:05
dtype: datetime64[ns]
DatetimeIndex(['2016-06-28 10:30:05-05:00', '2016-06-28 10:31:05-05:00'], dtype='datetime64[ns, America/Chicago]', freq=None)

Expected Output

2016-06-28 05:30:00-05:00   2016-06-28 05:30:05-05:00
2016-06-28 05:31:00-05:00   2016-06-28 05:31:05-05:00
dtype: datetime64[ns]
DatetimeIndex(['2016-06-28 05:30:05-05:00', '2016-06-28 05:31:05-05:00'], dtype='datetime64[ns, America/Chicago]', freq=None)

Note however that this does print the expected result:

print(index + pd.to_timedelta('00:00:05'))

I'm using Pandas 0.18.1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions