polars.internals.expr.ExprListNameSpace.head

ExprListNameSpace.head(n: int = 5) polars.internals.expr.Expr

Slice the head of every sublist

Parameters
n

How many values to take in the slice.

Examples

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