polars/polars-map-elements-native
| Rule | polars-map-elements-native |
|---|---|
| Pack | Polars |
| Severity | warning |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | every version |
Polars 2.1.0 emits PolarsInefficientMapWarning when map_elements wraps addition in this lambda. Add the value directly with a Polars expression.
expr.map_elements(lambda value: value + 1, return_dtype=pl.Int64)expr + 1What the rule reports
Section titled “What the rule reports”PolarsInefficientMapWarning under -W error.
How to fix it
Section titled “How to fix it”Use xpd check --fix --unsafe-fixes to replace the map_elements addition lambda with direct expression addition.
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 emits PolarsInefficientMapWarning when map_elements wraps addition in this lambda. Add the value directly with a Polars expression.Browse the other rules of the Polars pack.