DataFrame.rows(*, named: Literal[False] = False) list[tuple[Any, ...]][source]#
DataFrame.rows(*, named: Literal[True]) list[dict[str, Any]]

Returns all data in the DataFrame as a list of rows of python-native values.


Return dictionaries instead of tuples. The dictionaries are a mapping of column name to row value. This is more expensive than returning a regular tuple, but allows for accessing values by column name.

list of tuples (default) or dictionaries of row values


Row-iteration is not optimal as the underlying data is stored in columnar form; where possible, prefer export via one of the dedicated export/output methods. Where possible you should also consider using iter_rows instead to avoid materialising all the data at once.

See also


Row iterator over frame data (does not materialise all rows).


Materialises frame data as a key-indexed dictionary.


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).


>>> df = pl.DataFrame(
...     {
...         "x": ["a", "b", "b", "a"],
...         "y": [1, 2, 3, 4],
...         "z": [0, 3, 6, 9],
...     }
... )
>>> df.rows()
[('a', 1, 0), ('b', 2, 3), ('b', 3, 6), ('a', 4, 9)]
>>> df.rows(named=True)
[{'x': 'a', 'y': 1, 'z': 0},
 {'x': 'b', 'y': 2, 'z': 3},
 {'x': 'b', 'y': 3, 'z': 6},
 {'x': 'a', 'y': 4, 'z': 9}]