feat(python): Implement DataFrame Interchange Protocol through pyarrow
#6581
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow-up of #5662
Resolves #2249
Utilizes
pyarrow
's implementation of the DataFrame interchange protocol. Many thanks to @jorisvandenbossche and the pyarrow team for their work on this.Changes:
DataFrame.__dataframe__
for converting to the interchange formatpl.from_dataframe
for converting from the interchange formatLimitations:
pyarrow>=11.0.0
is requiredNotImplementedError
, indicating that we do not currently offer this, but are planning to in the future (either through better pyarrow integration, or utilizing our own implementation of the protocol).from_dataframe
in a zero-copy manner. This will throw aNotImplementedError
. We can refine this later by detecting which dtypes are present in the dataframe and determining if those can be handled in a zero-copy manner.So while there are some (significant) limitations on zero-copy conversions, we can now support the dataframe interchange protocol!