polars/polars-map-elements-native
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| Polars | warning | unsafe, with xpd check --fix --unsafe-fixes |
All versions |
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.
Diagnostic message
Section titled “Diagnostic message”Polars 2.1.0 emits PolarsInefficientMapWarning when map_elements wraps addition in this lambda. Add the value directly with a Polars expression.See all rules in the Polars pack.