pandas.api.typing.SeriesGroupBy.shift
pandas 3.1.1 · GroupBy · method
Move values by a positional offset. With a time frequency, move the labels instead.
Call syntax
pd.api.typing.SeriesGroupBy.shift(periods=1, freq=None, fill_value=…, suffix=None)Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
periods |
Optional Positional or keyword Default 1 |
int | Sequence[int] Set a count of generated observations or the number of steps to shift or compare. |
freq |
Optional Positional or keyword Default None |
str Specify the frequency or offset, such as "D" for a day or "MS" for a calendar month start. |
fill_value |
Optional Positional or keyword |
Supply a value to use in place of a missing position. |
suffix |
Optional Positional or keyword Default None |
str Set the text added to labels or the pattern used for wide-column suffixes. |
Returns
Series or DataFrame