Skip to content

polars/polars-list-get-oob

Rule polars-list-get-oob
Pack Polars
Severity info
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

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.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

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

Browse the other rules of the Polars pack.