Skip to content

polars/polars-join-asof-unsorted

Rule polars-join-asof-unsorted
Pack Polars
Severity info
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

An as-of join needs ascending join keys. Check that each input is sorted by the join key within each group.

df.join_asof(other, on="x", check_sortedness=False)
df.sort("x").join_asof(other.sort("x"), on="x")

Descending right keys raised InvalidOperationError with the default sortedness check.

With --unsafe-fixes, xpd enables the sortedness check. Sort the inputs if their keys are out of order.

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

An as-of join needs ascending join keys. Check that each input is sorted by the join key within each group.

Browse the other rules of the Polars pack.