Rick Kim
Rick Kim

Reputation: 21

Example of zero-copy share of a Polars dataframe between Python and Rust?

I have a Python function such as

def add_data(input_df): """ some manipulation of input_df (Polars dataframe) such as filling some columns with new values """

I would like to use this function from a Rust function. input_df can be tens of megabytes big, so I'd like to use zero-copy share between Python and Rust. Is there any example code on this available?

I found Is it possible to access underlying data from Polars in cython? but this seems to be Cython. I am looking for a pure Python way.

Upvotes: 2

Views: 966

Answers (1)

ritchie46
ritchie46

Reputation: 14690

I made a crate for this to make this easy: https://github.com/pola-rs/pyo3-polars

See the examples to get started: https://github.com/pola-rs/pyo3-polars/tree/main/example

Upvotes: 1

Related Questions