cudf.core.column.categorical.CategoricalAccessor.add_categories#

CategoricalAccessor.add_categories(new_categories: Any) SeriesOrIndex | None#

Add new categories.

new_categories will be included at the last/highest place in the categories and will be unused directly after this call.

Parameters:
new_categoriescategory or list-like of category

The new categories to be included.

Returns:
cat

Categorical with new categories added.

Examples

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