Skip to content

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

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

Edit the code using the replacement in the example.

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.