polars.Series.to_pandas#

Series.to_pandas(
*args: Any,
use_pyarrow_extension_array: bool = False,
**kwargs: Any,
) pd.Series[Any][source]#

Convert this Series to a pandas Series.

This requires that pandas and pyarrow are installed. This operation clones data, unless use_pyarrow_extension_array=True.

Parameters:
use_pyarrow_extension_array

Further operations on this Pandas series, might trigger conversion to numpy. Use PyArrow backed-extension array instead of numpy array for pandas Series. This allows zero copy operations and preservation of nulls values. Further operations on this pandas Series, might trigger conversion to NumPy arrays if that operation is not supported by pyarrow compute functions.

kwargs

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

Examples

>>> s1 = pl.Series("a", [1, 2, 3])
>>> s1.to_pandas()
0    1
1    2
2    3
Name: a, dtype: int64
>>> s1.to_pandas(use_pyarrow_extension_array=True)  
0    1
1    2
2    3
Name: a, dtype: int64[pyarrow]
>>> s2 = pl.Series("b", [1, 2, None, 4])
>>> s2.to_pandas()
0    1.0
1    2.0
2    NaN
3    4.0
Name: b, dtype: float64
>>> s2.to_pandas(use_pyarrow_extension_array=True)  
0       1
1       2
2    <NA>
3       4
Name: b, dtype: int64[pyarrow]