Skip to content

Commit 4a6ba1a

Browse files
author
KD-dev-lab
authored
TST: Added test to check that the freqstr attribute of the index is p… (#34572)
1 parent 8944b71 commit 4a6ba1a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/series/methods/test_shift.py

+16
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,19 @@ def test_shift_dt64values_int_fill_deprecated(self):
276276

277277
expected = pd.Series([pd.Timestamp(0), ser[0]])
278278
tm.assert_series_equal(result, expected)
279+
280+
@pytest.mark.parametrize("periods", [1, 2, 3, 4])
281+
def test_shift_preserve_freqstr(self, periods):
282+
# GH#21275
283+
ser = pd.Series(
284+
range(periods),
285+
index=pd.date_range("2016-1-1 00:00:00", periods=periods, freq="H"),
286+
)
287+
288+
result = ser.shift(1, "2H")
289+
290+
expected = pd.Series(
291+
range(periods),
292+
index=pd.date_range("2016-1-1 02:00:00", periods=periods, freq="H"),
293+
)
294+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)