polars.Series.list.to_map#
- Series.list.to_map() Series[source]#
Convert the
ListofStructentries to aMap.The input must be a
ListofStructwith exactly two fields namedkeyandvalue. Keys must not be null; duplicate keys within a row are resolved by keeping the first position and the last value.The inverse of
Series.map.entries().Examples
>>> s = pl.Series([[{"key": "a", "value": 1}, {"key": "b", "value": 2}]]) >>> s.list.to_map() shape: (1,) Series: '' [map[str, i64]] [ {"a": 1, "b": 2} ]