pyarrow.register_extension_type

pyarrow.register_extension_type(ext_type)

Register a Python extension type.

Registration is based on the extension name (so different registered types need unique extension names). Registration needs an extension type instance, but then works for any instance of the same subclass regardless of parametrization of the type.

Parameters:
ext_typeBaseExtensionType instance

The ExtensionType subclass to register.

Examples

Define a UuidType extension type subclassing ExtensionType:

>>> import pyarrow as pa
>>> class UuidType(pa.ExtensionType):
...    def __init__(self):
...       pa.ExtensionType.__init__(self, pa.binary(16), "my_package.uuid")
...    def __arrow_ext_serialize__(self):
...       # since we don't have a parameterized type, we don't need extra
...       # metadata to be deserialized
...       return b''
...    @classmethod
...    def __arrow_ext_deserialize__(self, storage_type, serialized):
...       # return an instance of this subclass given the serialized
...       # metadata.
...       return UuidType()
...

Register the extension type:

>>> pa.register_extension_type(UuidType())

Unregister the extension type:

>>> pa.unregister_extension_type("my_package.uuid")