File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class providing the base-class of operations.
10
10
11
11
from collections .abc import (
12
12
Hashable ,
13
+ Iterable ,
13
14
Iterator ,
14
15
Mapping ,
15
16
Sequence ,
@@ -4862,7 +4863,7 @@ def cummax(
4862
4863
@Substitution (name = "groupby" )
4863
4864
def shift (
4864
4865
self ,
4865
- periods : int = 1 ,
4866
+ periods : int | Iterable [ int ] = 1 ,
4866
4867
freq = None ,
4867
4868
axis : Axis | lib .NoDefault = lib .no_default ,
4868
4869
fill_value = None ,
@@ -4890,6 +4891,10 @@ def shift(
4890
4891
fill_value : optional
4891
4892
The scalar value to use for newly introduced missing values.
4892
4893
4894
+ suffix : str, optional
4895
+ A string to add to each shifted column if there are multiple periods.
4896
+ Ignored otherwise.
4897
+
4893
4898
Returns
4894
4899
-------
4895
4900
Series or DataFrame
@@ -4968,6 +4973,7 @@ def shift(
4968
4973
).add_suffix (f"{ suffix } _{ period } " if suffix else f"_{ period } " )
4969
4974
)
4970
4975
return concat (shifted_dataframes , axis = 1 ) if shifted_dataframes else self
4976
+ periods = cast (int , periods )
4971
4977
4972
4978
if freq is not None or axis != 0 :
4973
4979
f = lambda x : x .shift (periods , freq , axis , fill_value )
You can’t perform that action at this time.
0 commit comments