polars.internals.expr.ExprListNameSpace.get

ExprListNameSpace.get(index: int) polars.internals.expr.Expr

Get the value by index in the sublists. So index 0 would return the first item of every sublist and index -1 would return the last item of every sublist if an index is out of bounds, it will return a None.

Parameters
index

Index to return per sublist

Examples

>>> df = pl.DataFrame({"foo": [[3, 2, 1], [], [1, 2]]})
>>> df.select(pl.col("foo").arr.get(0))
shape: (3, 1)
┌──────┐
│ foo  │
│ ---  │
│ i64  │
╞══════╡
│ 3    │
├╌╌╌╌╌╌┤
│ null │
├╌╌╌╌╌╌┤
│ 1    │
└──────┘