cudf.Series.from_categorical#

classmethod Series.from_categorical(categorical, codes=None)#

Creates from a pandas.Categorical

Parameters:
categoricalpandas.Categorical

Contains data stored in a pandas Categorical.

codesarray-like, optional.

The category codes of this categorical. If codes are defined, they are used instead of categorical.codes

Returns:
Series

A cudf categorical series.

Examples

>>> import cudf
>>> import pandas as pd
>>> pd_categorical = pd.Categorical(pd.Series(['a', 'b', 'c', 'a'], dtype='category'))
>>> pd_categorical
['a', 'b', 'c', 'a']
Categories (3, object): ['a', 'b', 'c']
>>> series = cudf.Series.from_categorical(pd_categorical)
>>> series
0    a
1    b
2    c
3    a
dtype: category
Categories (3, object): ['a', 'b', 'c']