modin.pandas.DataFrame.diff¶
- DataFrame.diff(periods=1, axis=0) Self[source]¶
First discrete difference of element.
Calculates the difference of a DataFrame element compared with another element in the DataFrame (default is element in previous row).
- Parameters:
periods (int, default 1) – Periods to shift for calculating difference, accepts negative values.
axis ({0 or 'index', 1 or 'columns'}, default 0) – Take difference over rows (0) or columns (1).
- Returns:
DataFrame with the first differences of the Series.
- Return type:
Notes
For boolean dtypes, this uses operator.xor() rather than operator.sub(). The result is calculated according to current dtype in DataFrame, however dtype of the result is always float64.
Examples
Difference with previous row
Difference with previous column
Difference with 3rd previous row
Difference with following row