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)What the rule reports
Section titled “What the rule reports”Three collect calls produced the same three frames as collect_all in the probe.
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.
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.