-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: support Arrow PyCapsule Interface on Series for export (#59587)
* ENH: support Arrow PyCapsule Interface on Series for export * simplify * simplify
- Loading branch information
1 parent
d31aa83
commit bb4ab4f
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import ctypes | ||
|
||
import pytest | ||
|
||
import pandas as pd | ||
|
||
pa = pytest.importorskip("pyarrow", minversion="16.0") | ||
|
||
|
||
def test_series_arrow_interface(): | ||
s = pd.Series([1, 4, 2]) | ||
|
||
capsule = s.__arrow_c_stream__() | ||
assert ( | ||
ctypes.pythonapi.PyCapsule_IsValid( | ||
ctypes.py_object(capsule), b"arrow_array_stream" | ||
) | ||
== 1 | ||
) | ||
|
||
ca = pa.chunked_array(s) | ||
expected = pa.chunked_array([[1, 4, 2]]) | ||
assert ca.equals(expected) |