CategoricalIndex.
add_categories
Add new categories.
new_categories will be included at the last/highest place in the categories and will be unused directly after this call.
The new categories to be included.
Whether or not to add the categories inplace or return a copy of this categorical with added categories.
Deprecated since version 3.2.0.
Categorical with new categories added or None if inplace=True.
inplace=True
If the new categories include old categories or do not validate as categories
See also
rename_categories
Rename categories.
reorder_categories
Reorder categories.
remove_categories
Remove the specified categories.
remove_unused_categories
Remove categories which are not used.
set_categories
Set the categories to the specified ones.
Examples
>>> idx = ps.CategoricalIndex(list("abbccc")) >>> idx CategoricalIndex(['a', 'b', 'b', 'c', 'c', 'c'], categories=['a', 'b', 'c'], ordered=False, dtype='category')
>>> idx.add_categories('x') CategoricalIndex(['a', 'b', 'b', 'c', 'c', 'c'], categories=['a', 'b', 'c', 'x'], ordered=False, dtype='category')