pandas.api.typing.SeriesGroupBy.diff

pandas 3.1.1 · GroupBy · method

Subtract an earlier observation from the current one. Change periods to adjust the distance.

Call syntax

pd.api.typing.SeriesGroupBy.diff(periods=1)

Run the example

Edit the example and select Run Python to see the result.

Parameters

ParameterRequirementAccepted values and behavior
periods Optional
Positional or keyword
Default 1
int

Set a count of generated observations or the number of steps to shift or compare.

Returns

Series or DataFrame