set_categories(self, new_categories, ordered=None, rename=False, inplace=<no_default>)
:None:None:`new_categories`
can include new categories (which will result in unused categories) or remove old categories (which results in values set to NaN). If :None:None:`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, which does not considers a S1 string equal to a single char python string.
The categories in new order.
Whether or not the categorical is treated as a ordered categorical. If not given, do not change the ordered information.
Whether or not the new_categories should be considered as a rename of the old categories or as reordered categories.
Whether or not to reorder the categories in-place or return a copy of this categorical with reordered categories.
If new_categories does not validate as categories
Set the categories to the specified new_categories.
add_categories
Add new categories.
remove_categories
Remove the specified categories.
remove_unused_categories
Remove categories which are not used.
rename_categories
Rename categories.
reorder_categories
Reorder categories.
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.arrays.categorical.Categorical.remove_categories
pandas.core.arrays.categorical.Categorical.add_categories
pandas.core.arrays.categorical.Categorical.rename_categories
pandas.core.arrays.categorical.Categorical.remove_unused_categories
pandas.core.arrays.categorical.Categorical.reorder_categories
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them