Skip to content

Commit 8eee396

Browse files
committed
Merge pull request #9104 from jreback/dti_iteration
BUG: Bug in DatetimeIndex iteration, related to (GH8890), fixed in (GH9100)
2 parents f7af818 + 888d68f commit 8eee396

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

doc/source/whatsnew/v0.16.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@ Bug Fixes
5151

5252
- Fixed compatibility issue in ``DatetimeIndex`` affecting architectures where ``numpy.int_`` defaults to ``numpy.int32`` (:issue:`8943`)
5353
- Bug in ``MultiIndex.has_duplicates`` when having many levels causes an indexer overflow (:issue:`9075`)
54+
- Bug in DatetimeIndex iteration, related to (:issue:`8890`), fixed in (:issue:`9100`)

pandas/tseries/tests/test_timeseries.py

+10
Original file line numberDiff line numberDiff line change
@@ -2332,8 +2332,18 @@ def test_iteration_preserves_tz(self):
23322332
for i, ts in enumerate(index):
23332333
result = ts
23342334
expected = index[i]
2335+
self.assertEqual(result._repr_base, expected._repr_base)
23352336
self.assertEqual(result, expected)
23362337

2338+
# 9100
2339+
index = pd.DatetimeIndex(['2014-12-01 03:32:39.987000-08:00','2014-12-01 04:12:34.987000-08:00'])
2340+
for i, ts in enumerate(index):
2341+
result = ts
2342+
expected = index[i]
2343+
self.assertEqual(result._repr_base, expected._repr_base)
2344+
self.assertEqual(result, expected)
2345+
2346+
23372347
def test_misc_coverage(self):
23382348
rng = date_range('1/1/2000', periods=5)
23392349
result = rng.groupby(rng.day)

pandas/tslib.pyx

+4-3
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ def ints_to_pydatetime(ndarray[int64_t] arr, tz=None, offset=None, box=False):
128128
result[i] = NaT
129129
else:
130130
pandas_datetime_to_datetimestruct(value, PANDAS_FR_ns, &dts)
131-
dt = func_create(value, dts, tz, offset)
132-
if not box:
133-
dt = dt + tz.utcoffset(dt)
131+
dt = create_datetime_from_ts(value, dts, tz, offset)
132+
dt = dt + tz.utcoffset(dt)
133+
if box:
134+
dt = Timestamp(dt)
134135
result[i] = dt
135136
else:
136137
trans, deltas, typ = _get_dst_info(tz)

0 commit comments

Comments
 (0)