polars/polars-concat-in-loop
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Polars | info | none, edit by hand | All versions |
Concatenating into the same frame on every iteration repeatedly grows the result. Collect the pieces and concatenate once.
output = pl.concat([output, piece], rechunk=True)output = pl.concat(pieces, rechunk=True)What the rule reports
Section titled “What the rule reports”16.23x and 269.11x on 50,000 and 500,000 total rows across 25 batches with rechunk=True.
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”Concatenating into the same frame on every iteration repeatedly grows the result. Collect the pieces and concatenate once.See all rules in the Polars pack.