maxframe.liteframe.LiteFrame.diff#
- LiteFrame.diff(periods=1, columns=None)#
Compute
x[i] - x[i-periods]for each row.First
periodsrows (for positive periods) or last|periods|rows (for negative periods) are null.- Parameters:
- Returns:
Diffed LiteFrame with same shape and columns.
- Return type:
- Raises:
TypeError – If any transformed column is non-numeric.
See also
shiftShift rows by a given number of periods.
pct_changeCompute percent change over given periods.
Examples
>>> import maxframe.liteframe as mlf >>> lf = mlf.LiteFrame({'a': [1, 2, 4, 7]}) >>> result = lf.diff() >>> result.execute() a 0 NaN 1 1.0 2 2.0 3 3.0