New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jzwinck opened this Issue Aug 4, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@jzwinck
Contributor

jzwinck commented Aug 4, 2016

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.

@jreback

This comment has been minimized.

Contributor

jreback commented Aug 4, 2016

yep, thought we had an issue about this, but can't seem to find it.

@jreback jreback added this to the Next Major Release milestone Aug 4, 2016

jbrockmendel added a commit to jbrockmendel/pandas that referenced this issue Dec 20, 2017

Fix Series[timedelta64]+DatetimeIndex[tz] bugs
ser + index lossed timezone
closes pandas-dev#13905

index + ser retained timezone but returned a DatetimeIndex

@jreback jreback modified the milestones: Next Major Release, 0.23.0 Dec 21, 2017

jreback added a commit that referenced this issue Jan 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment