pandas 1.4.2

NotesBackRef

Notes

The interface includes the following abstract methods that must be implemented by subclasses:

The following attributes and methods influence the behavior of the dtype in pandas operations

The :None:None:`na_value` class attribute can be used to set the default NA value for this type. numpy.nan is used by default.

ExtensionDtypes are required to be hashable. The base class provides a default implementation, which relies on the _metadata class attribute. _metadata should be a tuple containing the strings that define your data type. For example, with PeriodDtype that's the freq attribute.

If you have a parametrized dtype you should set the ``_metadata`` class property.

Ideally, the attributes in _metadata will match the parameters to your ExtensionDtype.__init__ (if any). If any of the attributes in _metadata don't implement the standard __eq__ or __hash__ , the default implementations here will not work.

For interaction with Apache Arrow (pyarrow), a __from_arrow__ method can be implemented: this method receives a pyarrow Array or ChunkedArray as only argument and is expected to return the appropriate pandas ExtensionArray for this dtype and the passed values:

class ExtensionDtype:

    def __from_arrow__(
        self, array: Union[pyarrow.Array, pyarrow.ChunkedArray]
    ) -> ExtensionArray:
        ...

This class does not inherit from 'abc.ABCMeta' for performance reasons. Methods and properties required by the interface raise pandas.errors.AbstractMethodError and no register method is provided for registering virtual subclasses.

A custom data type, to be paired with an ExtensionArray.

See Also

extensions.ExtensionArray

Abstract base class for custom 1-D array types.

extensions.register_extension_dtype

Register an ExtensionType with pandas as class decorator.

Examples

See :

Back References

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

pandas.core.dtypes.base.register_extension_dtype

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/base.py#39
type: <class 'type'>
Commit: