polars/polars-concat-in-loop
| Rule | polars-concat-in-loop |
|---|---|
| Pack | Polars |
| Severity | info |
| Fix | none, edit by hand |
| Library versions | every version |
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.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
Concatenating into the same frame on every iteration repeatedly grows the result. Collect the pieces and concatenate once.Browse the other rules of the Polars pack.