Skip to content

polars/polars-list-get-oob

Pack Severity Fix Versions
Polars info unsafe, with xpd check --fix --unsafe-fixes All versions

Polars raises ComputeError for an out-of-bounds list offset by default. Pass null_on_oob=True when shorter lists are expected.

pl.Series([[1], [2, 3]]).list.get(1)
pl.Series([[1], [2, 3]]).list.get(1, null_on_oob=True)

Index 1 raised ComputeError for a one-item list. null_on_oob=True returned [None, 3].

Use xpd check --fix --unsafe-fixes to add null_on_oob=True to the list.get call.

Polars raises ComputeError for an out-of-bounds list offset by default. Pass null_on_oob=True when shorter lists are expected.

See all rules in the Polars pack.