Skip to content

Commit 83ff5b1

Browse files
committed
BUG: Bug in 32-bit platforms with Series.shift (GH8129)
1 parent 605d2fc commit 83ff5b1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

doc/source/v0.15.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ Bug Fixes
751751
- Bug in sorting a multi-index frame with a Float64Index (:issue:`8017`)
752752

753753
- Bug in ``is_superperiod`` and ``is_subperiod`` cannot handle higher frequencies than ``S`` (:issue:`7760`, :issue:`7772`, :issue:`7803`)
754-
754+
- Bug in 32-bit platforms with ``Series.shift`` (:issue:`8129`)
755755
- Bug in ``PeriodIndex.unique`` returns int64 ``np.ndarray`` (:issue:`7540`)
756756

757757
- Bug in ``DataFrame.reset_index`` which has ``MultiIndex`` contains ``PeriodIndex`` or ``DatetimeIndex`` with tz raises ``ValueError`` (:issue:`7746`, :issue:`7793`)

pandas/core/internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ def shift(self, periods, axis=0):
827827
axis = new_values.ndim - axis - 1
828828

829829
if np.prod(new_values.shape):
830-
new_values = np.roll(new_values, periods, axis=axis)
830+
new_values = np.roll(new_values, com._ensure_platform_int(periods), axis=axis)
831831

832832
axis_indexer = [ slice(None) ] * self.ndim
833833
if periods > 0:

pandas/tests/test_series.py

+10
Original file line numberDiff line numberDiff line change
@@ -4602,6 +4602,16 @@ def test_shift(self):
46024602
shifted5 = ps.shift(1, offset=datetools.bday)
46034603
assert_series_equal(shifted5, shifted4)
46044604

4605+
# 32-bit taking
4606+
# GH 8129
4607+
index=date_range('2000-01-01',periods=5)
4608+
for dtype in ['int32','int64']:
4609+
s1 = Series(np.arange(5,dtype=dtype),index=index)
4610+
p = s1.iloc[1]
4611+
result = s1.shift(periods=p)
4612+
expected = Series([np.nan,0,1,2,3],index=index)
4613+
assert_series_equal(result,expected)
4614+
46054615
def test_tshift(self):
46064616
# PeriodIndex
46074617
ps = tm.makePeriodSeries()

0 commit comments

Comments
 (0)