cudf.core.column.categorical.CategoricalAccessor.as_ordered#

CategoricalAccessor.as_ordered() SeriesOrIndex | None#

Set the Categorical to be ordered.

Returns:
Categorical

Ordered Categorical.

Examples

>>> import cudf
>>> s = cudf.Series([10, 1, 1, 2, 10, 2, 10], dtype="category")
>>> s
0    10
1     1
2     1
3     2
4    10
5     2
6    10
dtype: category
Categories (3, int64): [1, 2, 10]
>>> s.cat.as_ordered()
0    10
1     1
2     1
3     2
4    10
5     2
6    10
dtype: category
Categories (3, int64): [1 < 2 < 10]