polars.Series.arr.slice#

Series.arr.slice(offset: int, length: int | None = None) Series[source]#

Slice every sublist.

Parameters:
offset

Start index. Negative indexing is supported.

length

Length of the slice. If set to None (default), the slice is taken to the end of the list.

Examples

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