Skip to content

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()

1279.48x and 623.31x with equal sums on integer data.

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.

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.