pandas.core.groupby.DataFrameGroupBy.shift

DataFrameGroupBy.shift(self, periods=1, freq=None, axis=0, fill_value=None)[source]

Shift each group by periods observations.

Parameters
periodsint, default 1

Number of periods to shift.

freqfrequency string
axisaxis to shift, default 0
fill_valueoptional

New in version 0.24.0.

Returns
Series or DataFrame

Object shifted within each group.

See also

Series.groupby
DataFrame.groupby