pandas.DataFrame.diff

DataFrame.diff(periods=1, axis=0)[source]

1st discrete difference of object

Parameters:

periods : int, default 1

Periods to shift for forming difference

axis : {0 or ‘index’, 1 or ‘columns’}, default 0

Take difference over rows (0) or columns (1).

Returns:

diffed : DataFrame