CategoricalIndex, like Categorical, can only take on a limited, and usually fixed, number of possible values (:None:None:`categories`
). Also, like Categorical, it might have an order, but numerical operations (additions, divisions, ...) are not possible.
See the :None:None:`user guide
<https://pandas.pydata.org/pandas-docs/stable/user_guide/advanced.html#categoricalindex>`
for more.
The values of the categorical. If :None:None:`categories`
are given, values not in :None:None:`categories`
will be replaced with NaN.
The categories for the categorical. Items need to be unique. If the categories are not given here (and also not in dtype
), they will be inferred from the :None:None:`data`
.
Whether or not this categorical is treated as an ordered categorical. If not given here or in dtype
, the resulting categorical will be unordered.
If CategoricalDtype
, cannot be used together with :None:None:`categories`
or :None:None:`ordered`
.
Make a copy of input ndarray.
Name to be stored in the index.
If the categories do not validate.
If an explicit ordered=True
is given but no :None:None:`categories`
and the :None:None:`values`
are not sortable.
Index based on an underlying Categorical
.
Categorical
A categorical array.
CategoricalDtype
Type for categorical data.
Index
The base pandas Index type.
>>> pd.CategoricalIndex(["a", "b", "c", "a", "b", "c"]) CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'], categories=['a', 'b', 'c'], ordered=False, dtype='category')
CategoricalIndex
can also be instantiated from a Categorical
:
>>> c = pd.Categorical(["a", "b", "c", "a", "b", "c"])
... pd.CategoricalIndex(c) CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'], categories=['a', 'b', 'c'], ordered=False, dtype='category')
Ordered CategoricalIndex
can have a min and max value.
>>> ci = pd.CategoricalIndex(This example is valid syntax, but we were not able to check execution
... ["a", "b", "c", "a", "b", "c"], ordered=True, categories=["c", "b", "a"]
... )
... ci CategoricalIndex(['a', 'b', 'c', 'a', 'b', 'c'], categories=['c', 'b', 'a'], ordered=True, dtype='category')
>>> ci.min() 'c'See :
The following pages refer to to this document either explicitly or contain code examples using this.
pandas.core.arrays.categorical.Categorical
pandas.core.dtypes.concat.union_categoricals
pandas.core.indexes.base.Index.is_categorical
pandas.core.indexes.base.Index
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