Skip to content

polars/polars-mixed-dtype-arithmetic

Rule polars-mixed-dtype-arithmetic
Pack Polars
Severity error
Fix none, edit by hand
Library versions Polars 2.1 and later

Polars 2.1.0 rejects string and numeric Series arithmetic. Cast the strings explicitly, or use string concatenation for text.

pl.Series(["1"]) + pl.Series([2])
pl.Series(["1"]).cast(pl.Int64) + pl.Series([2])

InvalidOperationError for two Series. A string Series plus integer scalar raised TypeError.

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.

Polars 2.1.0 rejects string and numeric Series arithmetic. Cast the strings explicitly, or use string concatenation for text.

Browse the other rules of the Polars pack.