polars.Expr.list.shift#

Expr.list.shift(periods: int = 1) Expr[source]#

Shift values by the given period.

Parameters:
periods

Number of places to shift (may be negative).

Examples

>>> s = pl.Series("a", [[1, 2, 3, 4], [10, 2, 1]])
>>> s.list.shift()
shape: (2,)
Series: 'a' [list[i64]]
[
    [null, 1, … 3]
    [null, 10, 2]
]