Skip to content

BUG: Bug in DatetimeIndex iteration, related to (GH8890), fixed in (GH9100) #9104

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 19, 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.16.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ Bug Fixes

- Fixed compatibility issue in ``DatetimeIndex`` affecting architectures where ``numpy.int_`` defaults to ``numpy.int32`` (:issue:`8943`)
- Bug in ``MultiIndex.has_duplicates`` when having many levels causes an indexer overflow (:issue:`9075`)
- Bug in DatetimeIndex iteration, related to (:issue:`8890`), fixed in (:issue:`9100`)
10 changes: 10 additions & 0 deletions pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2332,8 +2332,18 @@ def test_iteration_preserves_tz(self):
for i, ts in enumerate(index):
result = ts
expected = index[i]
self.assertEqual(result._repr_base, expected._repr_base)
self.assertEqual(result, expected)

# 9100
index = pd.DatetimeIndex(['2014-12-01 03:32:39.987000-08:00','2014-12-01 04:12:34.987000-08:00'])
for i, ts in enumerate(index):
result = ts
expected = index[i]
self.assertEqual(result._repr_base, expected._repr_base)
self.assertEqual(result, expected)


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