How to pass Polars DataFrame as an argument to a function? #2494
Replies: 1 comment
-
Hmm, so what you're asking for is actually very hard - it's tracked in #1444. Basically, your pyo3 code has no knowledge of the polars Python wrappers. I think the only way I'm aware for this to happen is for the polars team to provide a stable C API which exposes the polars Python functionality, as well as manual implementations in the At the moment PyO3 has no primitives to help make this happen, and nothing has been designed. I'd be happy to see something added to PyO3 to meet this need, but it's a very very hard problem! |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to learn pyo3 and currently attempting to port some functionality of Polars to Python. I have the following code that has a struct and the corresponding impl for it. In one of the functions, I want to pass the DataFrame from the polars library https://docs.rs/polars/latest/polars/frame/struct.DataFrame.html# to one of the functions after which I do a simple calculation over the rows.
What I am struggling to understand is how should I wrap the DataFrame object? If I try to run
maturin develop
on the above code, I obtain an errorPyClass is not implemented for DataFrame
, which makes sense since it is not a native rust type. However having looked at the type table on https://pyo3.rs/v0.16.4/conversions/tables.html , I realise the answer lies somewhere with passing the object as a PyAny object (Or i could be completely wrong about that). Any help would be appreciated.Beta Was this translation helpful? Give feedback.
All reactions