polars/polars-selector-coercion
| Rule | polars-selector-coercion |
|---|---|
| Pack | Polars |
| Severity | info |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | Polars 2.0 and later |
A selector combined with col by &, | or ^ becomes a value expression in Polars 2.1.0. Use selectors.by_name to combine column selections.
cs.numeric() | pl.col("x")cs.numeric() | cs.by_name("x")What the rule reports
Section titled “What the rule reports”Taking the union of numeric columns and a string column as a value expression raised SchemaError. Two selectors selected 3 columns.
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to rewrite pl.col(...) with string column names to by_name(...) on the selector module.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
A selector combined with col by &, | or ^ becomes a value expression in Polars 2.1.0. Use selectors.by_name to combine column selections.Browse the other rules of the Polars pack.