Skip to content

Commit

Permalink
Add methods for the Arrow PyCapsule Protocol to DataFrame/Column inte…
Browse files Browse the repository at this point in the history
…rchange protocol objects
  • Loading branch information
jorisvandenbossche committed Dec 21, 2023
1 parent c5f0835 commit 25d830e
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions protocol/dataframe_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,41 @@ def get_buffers(self) -> ColumnBuffers:
"""
pass

def __arrow_c_schema__(self) -> object:
"""
Export the data type of the Column to a Arrow C schema PyCapsule.
Returns
-------
PyCapsule
"""
pass

def __arrow_c_array__(
self, requested_schema: Optional[object] = None
) -> Tuple[object, object]:
"""
Export the Column as an Arrow C array and schema PyCapsule.
If the Column consists of multiple chunks, this method should raise
an error.
Parameters
----------
requested_schema : PyCapsule, default None
The schema to which the dataframe should be casted, passed as a
PyCapsule containing a C ArrowSchema representation of the
requested schema.
If None, the array will be returned as-is, with a type matching the
one returned by ``__arrow_c_schema__()``.
Returns
-------
Tuple[PyCapsule, PyCapsule]
A pair of PyCapsules containing a C ArrowSchema and ArrowArray,
respectively.
"""
pass

# def get_children(self) -> Iterable[Column]:
# """
Expand Down Expand Up @@ -490,3 +525,32 @@ def get_chunks(self, n_chunks: Optional[int] = None) -> Iterable["DataFrame"]:
same way.
"""
pass

def __arrow_c_schema__(self) -> object:
"""
Export the schema of the DataFrae to a Arrow C schema PyCapsule.
Returns
-------
PyCapsule
"""
pass

def __arrow_c_stream__(self, requested_schema: Optional[object] = None) -> object:
"""
Export the DataFrame as an Arrow C stream PyCapsule.
Parameters
----------
requested_schema : PyCapsule, default None
The schema to which the dataframe should be casted, passed as a
PyCapsule containing a C ArrowSchema representation of the
requested schema.
If None, the array will be returned as-is, with a type matching the
one returned by ``__arrow_c_schema__()``.
Returns
-------
PyCapsule
"""
pass

0 comments on commit 25d830e

Please # to comment.