Skip to content

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 + 1

PolarsInefficientMapWarning under -W error.

Use xpd check --fix --unsafe-fixes to replace the map_elements addition lambda with direct expression addition.

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.