Skip to content

Commit 13eca16

Browse files
jorisvandenbosscheMateusz Górski
authored and
Mateusz Górski
committed
API/DOC: an ExtensionDtype.__from_arrow__ method to convert pyarrow.Array into ExtensionArray (pandas-dev#29229)
1 parent 1db7264 commit 13eca16

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pandas/core/dtypes/base.py

+12
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ class property**.
6363
Added ``_metadata``, ``__hash__``, and changed the default definition
6464
of ``__eq__``.
6565
66+
For interaction with Apache Arrow (pyarrow), a ``__from_arrow__`` method
67+
can be implemented: this method receives a pyarrow Array or ChunkedArray
68+
as only argument and is expected to return the appropriate pandas
69+
ExtensionArray for this dtype and the passed values::
70+
71+
class ExtensionDtype:
72+
73+
def __from_arrow__(
74+
self, array: pyarrow.Array/ChunkedArray
75+
) -> ExtensionArray:
76+
...
77+
6678
This class does not inherit from 'abc.ABCMeta' for performance reasons.
6779
Methods and properties required by the interface raise
6880
``pandas.errors.AbstractMethodError`` and no ``register`` method is

0 commit comments

Comments
 (0)