maxframe.liteframe.LiteFrame.pct_change#
- LiteFrame.pct_change(periods=1, columns=None)#
Compute
(x[i] - x[i-periods]) / x[i-periods]for each row.First
periodsrows (for positive periods) or last|periods|rows (for negative periods) are null. Division by zero produces null/inf following Polars arithmetic semantics.- Parameters:
- Returns:
Pct-change LiteFrame with same shape. Transformed columns become Float64.
- Return type:
- Raises:
TypeError – If any transformed column is non-numeric.
See also
Examples
>>> import maxframe.liteframe as mlf >>> lf = mlf.LiteFrame({'a': [100, 110, 121]}) >>> result = lf.pct_change() >>> result.execute() a 0 NaN 1 0.1 2 0.1