Skip to content

polars/polars-sequential-with-columns

Rule polars-sequential-with-columns
Pack Polars
Severity info
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

Chained with_columns calls may split work into separate steps. Combine independent expressions and keep later calls for expressions that use newly created columns.

df.with_columns(a=expr + 1).with_columns(b=expr + 2)
df.with_columns(a=expr + 1, b=expr + 2)

Independent expressions gave equal frames.

Use xpd check --fix --unsafe-fixes to combine chained with_columns calls when the second call does not depend on columns created in the first.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

Chained with_columns calls may split work into separate steps. Combine independent expressions and keep later calls for expressions that use newly created columns.

Browse the other rules of the Polars pack.