pandas 1.4.2

AttributesMethodsNotesParametersBackRef

Attributes

categories :
ordered :

Methods

Notes

This class is useful for specifying the type of a Categorical independent of the values. See categorical.categoricaldtype for more.

Parameters

categories : sequence, optional

Must be unique, and must not contain any nulls. The categories are stored in an Index, and if an index is provided the dtype of that index will be used.

ordered : bool or None, default False

Whether or not this categorical is treated as a ordered categorical. None can be used to maintain the ordered value of existing categoricals when used in operations that combine categoricals, e.g. astype, and will resolve to False if there is no existing ordered to maintain.

Type for categorical data with the categories and orderedness.

See Also

Categorical

Represent a categorical variable in classic R / S-plus fashion.

Examples

This example is valid syntax, but we were not able to check execution
>>> t = pd.CategoricalDtype(categories=['b', 'a'], ordered=True)
... pd.Series(['a', 'b', 'a', 'c'], dtype=t) 0 a 1 b 2 a 3 NaN dtype: category Categories (2, object): ['b' < 'a']

An empty CategoricalDtype with a specific dtype can be created by providing an empty index. As follows,

This example is valid syntax, but we were not able to check execution
>>> pd.CategoricalDtype(pd.DatetimeIndex([])).categories.dtype
dtype('<M8[ns]')
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

pandas.core.arrays.categorical.Categorical pandas.core.arrays.categorical.Categorical._set_dtype pandas.core.generic.NDFrame.astype pandas.core.indexes.category.CategoricalIndex

Local connectivity graph

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


File: /pandas/core/dtypes/dtypes.py#119
type: <class 'type'>
Commit: