pandas.api.types.is_categorical_dtype#

pandas.api.types.is_categorical_dtype(arr_or_dtype)[source]#

Check whether an array-like or dtype is of the Categorical dtype.

Deprecated since version 2.2.0: Use isinstance(dtype, pd.CategoricalDtype) instead.

Parameters:
arr_or_dtypearray-like or dtype

The array-like or dtype to check.

Returns:
boolean

Whether or not the array-like or dtype is of the Categorical dtype.

See also

api.types.is_list_like

Check if the object is list-like.

api.types.is_complex_dtype

Check whether the provided array or dtype is of a complex dtype.

Examples

>>> from pandas.api.types import is_categorical_dtype
>>> from pandas import CategoricalDtype
>>> is_categorical_dtype(object)
False
>>> is_categorical_dtype(CategoricalDtype())
True
>>> is_categorical_dtype([1, 2, 3])
False
>>> is_categorical_dtype(pd.Categorical([1, 2, 3]))
True
>>> is_categorical_dtype(pd.CategoricalIndex([1, 2, 3]))
True