polars.internals.series.ListNameSpace.shift

ListNameSpace.shift(periods: int = 1) polars.internals.series.Series

Shift the values by a given period and fill the parts that will be empty due to this operation with nulls.

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]
]