polars.internals.expr.list.ExprListNameSpace.shift#

ExprListNameSpace.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.arr.shift()
shape: (2,)
Series: 'a' [list]
[
    [null, 1, ... 3]
    [null, 10, 2]
]