cudf.core.dtypes.CategoricalDtype#

class cudf.core.dtypes.CategoricalDtype(categories=None, ordered: bool = False)#

Type for categorical data with the categories and orderedness.

Parameters:
categoriessequence, optional

Must be unique, and must not contain any nulls. The categories are stored in an Index, and if an index is provided the dtype of that index will be used.

orderedbool or None, default False

Whether or not this categorical is treated as a ordered categorical. None can be used to maintain the ordered value of existing categoricals when used in operations that combine categoricals, e.g. astype, and will resolve to False if there is no existing ordered to maintain.

Examples

>>> import cudf
>>> dtype = cudf.CategoricalDtype(categories=['b', 'a'], ordered=True)
>>> cudf.Series(['a', 'b', 'a', 'c'], dtype=dtype)
0       a
1       b
2       a
3    <NA>
dtype: category
Categories (2, object): ['b' < 'a']

Attributes

categories

An Index containing the unique categories allowed.

ordered

Whether the categories have an ordered relationship.

Methods

from_pandas(dtype)

Convert a pandas.CategrocialDtype to cudf.CategoricalDtype

to_pandas()

Convert a cudf.CategoricalDtype to pandas.CategoricalDtype