polars/polars-row-iteration
| Rule | polars-row-iteration |
|---|---|
| Pack | Polars |
| Severity | info |
| Fix | none, edit by hand |
| Library versions | every version |
Use a Polars expression to compute a reduction over rows. A column sum ran 1,279 and 623 times faster on 50,000 and 500,000 rows.
sum(row[0] for row in df.iter_rows())df["x"].sum()What the rule reports
Section titled “What the rule reports”1279.48x and 623.31x with equal sums on integer data.
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.
Use a Polars expression to compute a reduction over rows. A column sum ran 1,279 and 623 times faster on 50,000 and 500,000 rows.Browse the other rules of the Polars pack.