Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ from pandas._typing import (
FilePath,
FillnaOptions,
FormattersType,
Frequency,
GroupByObjectNonScalar,
HashableT,
HashableT1,
Expand Down Expand Up @@ -855,7 +856,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
def shift(
self,
periods: int = ...,
freq=...,
freq: Frequency | dt.timedelta | None = ...,
axis: Axis = ...,
fill_value: Hashable | None = ...,
) -> Self: ...
Expand Down
3 changes: 2 additions & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ from pandas._typing import (
FilePath,
FillnaOptions,
FloatDtypeArg,
Frequency,
GroupByObjectNonScalar,
HashableT1,
IgnoreRaise,
Expand Down Expand Up @@ -1219,7 +1220,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
def shift(
self,
periods: int = ...,
freq=...,
freq: Frequency | timedelta | None = ...,
axis: AxisIndex = ...,
fill_value: object | None = ...,
) -> Series[S1]: ...
Expand Down
5 changes: 4 additions & 1 deletion tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,13 @@ def test_types_sort_values_with_key() -> None:


def test_types_shift() -> None:
df = pd.DataFrame(data={"col1": [1, 1], "col2": [3, 4]})
df = pd.DataFrame(
data={"col1": [1, 1], "col2": [3, 4]}, index=pd.date_range("2020", periods=2)
)
df.shift()
df.shift(1)
df.shift(-1)
df.shift(freq="1D")


def test_types_rank() -> None:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,11 @@ def test_types_sort_values_with_key() -> None:


def test_types_shift() -> None:
s = pd.Series([1, 2, 3])
s = pd.Series([1, 2, 3], index=pd.date_range("2020", periods=3))
s.shift()
s.shift(axis=0, periods=1)
s.shift(-1, fill_value=0)
s.shift(freq="1D")


def test_types_rank() -> None:
Expand Down