polars.DataFrame.to_dicts#

DataFrame.to_dicts() list[dict[str, Any]][source]#

Convert every row to a dictionary.

Note that this is slow.

Examples

>>> df = pl.DataFrame({"foo": [1, 2, 3], "bar": [4, 5, 6]})
>>> df.to_dicts()
[{'foo': 1, 'bar': 4}, {'foo': 2, 'bar': 5}, {'foo': 3, 'bar': 6}]