polars.DataFrame.to_pandas#

DataFrame.to_pandas(*args: Any, date_as_object: bool = False, **kwargs: Any) DataFrame[source]#

Cast to a pandas DataFrame.

This requires that pandas and pyarrow are installed. This operation clones data.

Parameters:
args

Arguments will be sent to pyarrow.Table.to_pandas().

date_as_object

Cast dates to objects. If False, convert to datetime64[ns] dtype.

kwargs

Arguments will be sent to pyarrow.Table.to_pandas().

Returns:
pandas.DataFrame

Examples

>>> import pandas
>>> df = pl.DataFrame(
...     {
...         "foo": [1, 2, 3],
...         "bar": [6, 7, 8],
...         "ham": ["a", "b", "c"],
...     }
... )
>>> pandas_df = df.to_pandas()
>>> type(pandas_df)
<class 'pandas.core.frame.DataFrame'>