pandas.api.extensions.register_extension_dtype#

pandas.api.extensions.register_extension_dtype(cls)[source]#

Register an ExtensionType with pandas as class decorator.

This enables operations like .astype(name) for the name of the ExtensionDtype.

Returns:
callable

A class decorator.

See also

api.extensions.ExtensionDtype

The base class for creating custom pandas data types.

Series

One-dimensional array with axis labels.

DataFrame

Two-dimensional, size-mutable, potentially heterogeneous tabular data.

Examples

>>> from pandas.api.extensions import register_extension_dtype, ExtensionDtype
>>> @register_extension_dtype
... class MyExtensionDtype(ExtensionDtype):
...     name = "myextension"