Skip to content

polars/polars-collect-in-loop

Rule polars-collect-in-loop
Pack Polars
Severity info
Fix none, edit by hand
Library versions every version

Collect inside a loop can execute a separate query on each iteration. Build the queries first and use collect_all when they are independent.

lf.collect()
pl.collect_all([lf] * 3)

Three collect calls produced the same three frames as collect_all in the probe.

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.

Collect inside a loop can execute a separate query on each iteration. Build the queries first and use collect_all when they are independent.

Browse the other rules of the Polars pack.