polars.DataFrame.to_dicts
-
Convert every row to a dictionary of Python-native values.
Notes
If you have
ns-precision temporal values you should be aware that Python natively only supports up toμs-precision;ns-precision values will be truncated to microseconds on conversion to Python. If this matters to your use-case you should export to a different format (such as Arrow or NumPy).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}]
DataFrame.to_dicts() → list[dict[str, Any]]
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.to_dicts.html