Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support large strings in interchange protocol #56772

Merged
merged 4 commits into from
Jan 9, 2024

Conversation

phofl
Copy link
Member

@phofl phofl commented Jan 7, 2024

cc @MarcoGorelli

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!

If I run

df = pd.Series([], name="a", dtype="large_string[pyarrow]").to_frame()
dfi = df.__dataframe__()
result = pd.api.interchange.from_dataframe(dfi)
print(dfi.__dataframe__().get_column_by_name('a').get_buffers()['data'])

then I get

(PandasBuffer({'bufsize': 0, 'ptr': 94739763740952, 'device': 'CPU'}), (<DtypeKind.STRING: 21>, 8, 'u', '='))

I think it should be 'U' at the end?

I think you just need to update

# Define the dtype for the returned buffer
dtype = (
DtypeKind.STRING,
8,
ArrowCTypes.STRING,
Endianness.NATIVE,
) # note: currently only support native endianness

@WillAyd
Copy link
Member

WillAyd commented Jan 8, 2024

That may also fix #56754

@WillAyd WillAyd added the Interchange Dataframe Interchange Protocol label Jan 8, 2024
@phofl phofl added this to the 2.2 milestone Jan 8, 2024
@phofl
Copy link
Member Author

phofl commented Jan 8, 2024

@MarcoGorelli Does your commit fix the issue you detected earlier? If yes, we could backport to 2.2

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @phofl !

@MarcoGorelli MarcoGorelli merged commit f0cdc7c into pandas-dev:main Jan 9, 2024
48 of 50 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Jan 9, 2024
@phofl phofl deleted the 56702 branch January 9, 2024 08:42
@phofl
Copy link
Member Author

phofl commented Jan 9, 2024

Thanks to you :)

MarcoGorelli pushed a commit that referenced this pull request Jan 9, 2024
…nge protocol) (#56795)

Backport PR #56772: Support large strings in interchange protocol

Co-authored-by: Patrick Hoefler <61934744+phofl@users.noreply.github.com>
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* Support large strings in interchange protocol

* Update test_impl.py

* fixup buffer dtype, add todo

* add whatsnew

---------

Co-authored-by: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Interchange Dataframe Interchange Protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Support large string types in the interchange protocol
3 participants