Skip to content

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)

16.23x and 269.11x on 50,000 and 500,000 total rows across 25 batches with rechunk=True.

Edit the code using the replacement in the example.

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.