Код: Выделить всё
import polars as pl
my_dict = {
'a': 1,
'b': 2,
}
my_df = pl.DataFrame({'region': ['a', 'b', 'a']})
Код: Выделить всё
┌────────┐
│ region │
│ --- │
│ str │
╞════════╡
│ a │
│ b │
│ a │
└────────┘
Код: Выделить всё
pl.DataFrame({'region': ['a', 'b', 'a'], 'city': [1, 2, 1]})
Код: Выделить всё
┌────────┬──────┐
│ region ┆ city │
│ --- ┆ --- │
│ str ┆ i64 │
╞════════╪══════╡
│ a ┆ 1 │
│ b ┆ 2 │
│ a ┆ 1 │
└────────┴──────┘
Подробнее здесь: https://stackoverflow.com/questions/796 ... -to-a-dict