Taking the example straight from the docs:
import polars as pl
country_code_dict = {
"CA": "Canada",
"DE": "Germany",
"FR": "France",
None: "Not specified",
}
df = pl.DataFrame(
{
"country_code": ["FR", None, "ES", "DE"],
}
).with_row_count()
df.with_columns(
pl.col("country_code")
.map_dict(country_code_dict, default="unknown")
.alias("remapped")
)
here: https://pola-rs.github.io/polars/py-polars/html/reference/expressions/api/polars.Expr.map_dict.html
Gives the error: AttributeError: 'Expr' object has no attribute 'map_dict'
Is there another way to do this mapping operation?
map_dictwas added in 0.16.3: what's your version (print(pl.__version__))?