polars/polars-groupby-join-over
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Polars | info | none, edit by hand | All versions |
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"))What the rule reports
Section titled “What the rule reports”Three rows with non-null keys gave equal frames.
How to fix it
Section titled “How to fix it”Edit the code using the replacement in the example.
Diagnostic message
Section titled “Diagnostic message”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.See all rules in the Polars pack.