cudf.CategoricalIndex#

class cudf.CategoricalIndex(data, *args, **kwargs)#

A categorical of orderable values that represent the indices of another Column

Parameters:
dataarray-like (1-dimensional)

The values of the categorical. If categories are given, values not in categories will be replaced with None/NaN.

categorieslist-like, optional

The categories for the categorical. Items need to be unique. If the categories are not given here (and also not in dtype), they will be inferred from the data.

orderedbool, optional

Whether or not this categorical is treated as an ordered categorical. If not given here or in dtype, the resulting categorical will be unordered.

dtypeCategoricalDtype or “category”, optional

If CategoricalDtype, cannot be used together with categories or ordered.

copybool, default False

Make a copy of input.

nameobject, optional

Name to be stored in the index.

Returns:
CategoricalIndex

Examples

>>> import cudf
>>> import pandas as pd
>>> cudf.CategoricalIndex(
... data=[1, 2, 3, 4], categories=[1, 2], ordered=False, name="a")
CategoricalIndex([1, 2, <NA>, <NA>], categories=[1, 2], ordered=False, dtype='category', name='a')
>>> cudf.CategoricalIndex(
... data=[1, 2, 3, 4], dtype=pd.CategoricalDtype([1, 2, 3]), name="a")
CategoricalIndex([1, 2, 3, <NA>], categories=[1, 2, 3], ordered=False, dtype='category', name='a')

Attributes

codes

The category codes of this categorical.

categories

The categories of this categorical.

Methods

equals(other)

Test whether two objects contain the same elements.