cudf.Series.to_pandas#
- Series.to_pandas(*, index: bool = True, nullable: bool = False, arrow_type: bool = False) Series [source]#
Convert to a pandas Series.
- Parameters:
- indexBoolean, Default True
If
index
isTrue
, converts the index of cudf.Series and sets it to the pandas.Series. Ifindex
isFalse
, no index conversion is performed and pandas.Series will assign a default index.- nullableBoolean, Default False
If
nullable
isTrue
, the resulting series will be having a corresponding nullable Pandas dtype. If there is no corresponding nullable Pandas dtype present, the resulting dtype will be a regular pandas dtype. Ifnullable
isFalse
, the resulting series will either convert null values tonp.nan
orNone
depending on the dtype.- arrow_typebool, Default False
Return the Series with a
pandas.ArrowDtype
- Returns:
- outpandas Series
Notes
nullable and arrow_type cannot both be set to
True
Examples
>>> import cudf >>> ser = cudf.Series([-3, 2, 0]) >>> pds = ser.to_pandas() >>> pds 0 -3 1 2 2 0 dtype: int64 >>> type(pds) <class 'pandas.core.series.Series'>
nullable=True
converts the result to pandas nullable types:>>> ser = cudf.Series([10, 20, None, 30]) >>> ser 0 10 1 20 2 <NA> 3 30 dtype: int64 >>> ser.to_pandas(nullable=True) 0 10 1 20 2 <NA> 3 30 dtype: Int64 >>> ser.to_pandas(nullable=False) 0 10.0 1 20.0 2 NaN 3 30.0 dtype: float64
arrow_type=True
converts the result topandas.ArrowDtype
:>>> ser.to_pandas(arrow_type=True) 0 10 1 20 2 <NA> 3 30 dtype: int64[pyarrow]