daft.DataFrame.to_pylist

daft.DataFrame.to_pylist#

DataFrame.to_pylist() List[Any][source]#

Converts the current Dataframe into a python list. .. WARNING:

This is a convenience method over :meth:`DataFrame.iter_rows() <daft.DataFrame.iter_rows>`. Users should prefer using `.iter_rows()` directly instead for lower memory utilization if they are streaming rows out of a DataFrame and don't require full materialization of the Python list.

See also

df.iter_rows(): streaming iterator over individual rows in a DataFrame

Example

>>> import daft
>>> from daft import col
>>> df = daft.from_pydict({"a": [1, 2, 3, 4], "b": [2, 4, 3, 1]})
>>> print(df.to_pylist())
[{'a': 1, 'b': 2}, {'a': 2, 'b': 4}, {'a': 3, 'b': 3}, {'a': 4, 'b': 1}]
Returns:

List of python dict objects.

Return type:

List[dict[str, Any]]