polars/polars-row-iteration
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Polars | info | none, edit by hand | All versions |
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.
Diagnostic message
Section titled “Diagnostic message”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.See all rules in the Polars pack.