-
Notifications
You must be signed in to change notification settings - Fork 89
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
[Enh]: Construct DataFrame from Arrow PyCapsule object #1158
Comments
I think there can be a limited use case for passing around raw capsules, but the more general API is if you exported an object from your rust code with an In my own libraries, when I control both sides of the connection, I sometimes do have a |
Is import already possible in Narwhals? I was under the impression that it was currently only supported on export. A |
Oh maybe it's only for export? I'm not up to date. |
This is definitely in-scope, thanks for the request, I'll try to put something together soon-ish and we can figure out the details |
I've given this a go in #1181, does it look alright / is it what you were looking for? For libraries which don't (yet?) support the PyCapsule interface for import, I'm first using PyArrow (if installed and at least version 14) and then converting from there (the currently-supported libraries all have a way of going directly from pyarrow tables) |
Awesome, this looks great. Thanks so much for the quick implementation! |
@jonmmease are you looking for an API that takes a capsule or an API that takes a Python object that exports a capsule object? Your first example seemed to be the former, but #1181 implements the latter (I think the latter is more useful for more end users, while the former could be useful from native code specifically) In arro3 I have both |
Either is fine on my end. In practice I think I'll be returning an |
In that case just the |
We would like to learn about your use case. For example, if this feature is needed to adopt Narwhals in an open source project, could you please enter the link to it below?
This request is towards using narwhals to remove the pandas/pyarrow dependencies from VegaFusion 2.0
Please describe the purpose of the new feature or describe the problem to solve.
The flow I'm aiming for with VegaFusion 2.0 is that I'd like to use Narwhals for basic column projection and schema inspection and then use the Arrow PyCapsule API to pass the result to Rust. Then in some cases, the Rust logic will return a new Arrow result in PyCapsule form, and it would be great to be able to use Narwhals to wrap this result using the same backend as the input.
Suggest a solution if possible.
I was picturing perhaps a constructor method in the same family as
from_dict
, accepting an arrow PyCapsule object.cc @kylebarron for all things Arrow PyCapsule 😄
If you have tried alternatives, please describe them below.
No response
Additional information that may help us understand your needs.
No response
The text was updated successfully, but these errors were encountered: