CategoricalIndex.set_categories(self, *args, **kwargs)
[source]
Set the categories to the specified new_categories.
new_categories
can include new categories (which will result in unused categories) or remove old categories (which results in values set to NaN). If rename==True
, the categories will simple be renamed (less or more items than in old categories will result in values set to NaN or in unused categories respectively).
This method can be used to perform more than one action of adding, removing, and reordering simultaneously and is therefore faster than performing the individual steps via the more specialised methods.
On the other hand this methods does not do checks (e.g., whether the old categories are included in the new categories on a reorder), which can result in surprising changes, for example when using special string dtypes on python3, which does not considers a S1 string equal to a single char python string.
Parameters: |
|
---|---|
Returns: |
|
Raises: |
|
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.25.0/reference/api/pandas.CategoricalIndex.set_categories.html