pandas.api.types.is_extension_array_dtype

pandas.api.types.is_extension_array_dtype(arr_or_dtype) → bool[source]

Check if an object is a pandas extension array type.

See the Use Guide for more.

Parameters
arr_or_dtypeobject

For array-like input, the .dtype attribute will be extracted.

Returns
bool

Whether the arr_or_dtype is an extension array type.

Notes

This checks whether an object implements the pandas extension array interface. In pandas, this includes:

  • Categorical

  • Sparse

  • Interval

  • Period

  • DatetimeArray

  • TimedeltaArray

Third-party libraries may implement arrays or types satisfying this interface as well.

Examples

>>> from pandas.api.types import is_extension_array_dtype
>>> arr = pd.Categorical(['a', 'b'])
>>> is_extension_array_dtype(arr)
True
>>> is_extension_array_dtype(arr.dtype)
True
>>> arr = np.array(['a', 'b'])
>>> is_extension_array_dtype(arr.dtype)
False