Skip to content

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

Taking the union of numeric columns and a string column as a value expression raised SchemaError. Two selectors selected 3 columns.

Use xpd check --fix --unsafe-fixes to rewrite pl.col(...) with string column names to by_name(...) on the selector module.

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.