pandas.core.groupby.DataFrameGroupBy.shift
- DataFrameGroupBy. shift ( periods=1, freq=None, axis=0, fill_value=None ) [source]
-
Shift each group by periods observations.
If freq is passed, the index will be increased using the periods and the freq.
- Parameters
-
- periods :int, default 1
-
Number of periods to shift.
- freq :str, optional
-
Frequency string.
- axis :axis to shift, default 0
-
Shift direction.
- fill_value :optional
-
The scalar value to use for newly introduced missing values.
- Returns
-
- Series or DataFrame
-
Object shifted within each group.
See also
-
Index.shift
-
Shift values of Index.
-
tshift
-
Shift the time index, using the index’s frequency if available.
© 2008–2022, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/1.4.0/reference/api/pandas.core.groupby.DataFrameGroupBy.shift.html