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])What the rule reports
Section titled “What the rule reports”InvalidOperationError for two Series. A string Series plus integer scalar raised TypeError.
How to fix it
Section titled “How to fix it”Edit the code using the replacement in the example.
Message
Section titled “Message”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.