Anonymous
Polars AttributeError: объект «Expr» не имеет атрибута «map_dict» [дубликат]
Сообщение
Anonymous » 04 ноя 2025, 02:28
Пример прямо из документации:
Код: Выделить всё
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")
)
здесь:
https://pola-rs.github.io/polars/py-pol ... _dict.html
Выдает ошибку: AttributeError: объект 'Expr' не имеет атрибута 'map_dict'
Есть ли другой способ выполнить эту операцию сопоставления?>
Подробнее здесь:
https://stackoverflow.com/questions/758 ... e-map-dict
1762212515
Anonymous
Пример прямо из документации: [code]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") ) [/code] здесь: https://pola-rs.github.io/polars/py-polars/html/reference/expressions/api/polars.Expr.map_dict.html Выдает ошибку: AttributeError: объект 'Expr' не имеет атрибута 'map_dict' Есть ли другой способ выполнить эту операцию сопоставления?> Подробнее здесь: [url]https://stackoverflow.com/questions/75832154/polars-attributeerror-expr-object-has-no-attribute-map-dict[/url]