Skip to content

polars/polars-groupby-join-over

Rule polars-groupby-join-over
Pack Polars
Severity info
Fix none, edit by hand
Library versions every version

A join to an aggregation of the same Polars frame can often be written as a window expression. Check the output names and how null keys should be grouped.

df.join(df.group_by("y").agg(total=expr.sum()), on="y")
df.with_columns(total=expr.sum().over("y"))

Three rows with non-null keys gave equal frames.

Edit the code using the replacement in the example.

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

A join to an aggregation of the same Polars frame can often be written as a window expression. Check the output names and how null keys should be grouped.

Browse the other rules of the Polars pack.