Skip to content

REGR: Regression in DatetimeIndex iteration with a Fixed/Local offset timezone (GH8890) #8990

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

Merged
merged 1 commit into from
Dec 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.15.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Bug Fixes
s.loc['c':'a':-1]

- Report a ``TypeError`` when invalid/no paramaters are passed in a groupby (:issue:`8015`)
- Regression in DatetimeIndex iteration with a Fixed/Local offset timezone (:issue:`8890`)
- Bug in packaging pandas with ``py2app/cx_Freeze`` (:issue:`8602`, :issue:`8831`)
- Bug in ``groupby`` signatures that didn't include \*args or \*\*kwargs (:issue:`8733`).
- ``io.data.Options`` now raises ``RemoteDataError`` when no expiry dates are available from Yahoo and when it receives no data from Yahoo (:issue:`8761`), (:issue:`8783`).
Expand Down
21 changes: 21 additions & 0 deletions pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,27 @@ def test_map(self):
exp = [f(x) for x in rng]
self.assert_numpy_array_equal(result, exp)


def test_iteration_preserves_tz(self):

tm._skip_if_no_dateutil()

# GH 8890
import dateutil
index = date_range("2012-01-01", periods=3, freq='H', tz='US/Eastern')

for i, ts in enumerate(index):
result = ts
expected = index[i]
self.assertEqual(result, expected)

index = date_range("2012-01-01", periods=3, freq='H', tz=dateutil.tz.tzoffset(None, -28800))

for i, ts in enumerate(index):
result = ts
expected = index[i]
self.assertEqual(result, expected)

def test_misc_coverage(self):
rng = date_range('1/1/2000', periods=5)
result = rng.groupby(rng.day)
Expand Down
4 changes: 3 additions & 1 deletion pandas/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None, offset=None, box=False):
else:
pandas_datetime_to_datetimestruct(value, PANDAS_FR_ns, &dts)
dt = func_create(value, dts, tz, offset)
result[i] = dt + tz.utcoffset(dt)
if not box:
dt = dt + tz.utcoffset(dt)
result[i] = dt
else:
trans = _get_transitions(tz)
deltas = _get_deltas(tz)
Expand Down