You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I am a beginner in Rust while exploring with Polars dataframe in rust I encountored an error where I am not able to transfer my dataframe from rust to python
This is My Rust Code
use pyo3::prelude::*;
use polars::prelude::*;
use pyo3_polars::PyDataFrame;
#[pyfunction]
pub fn read_file(filepath: &str) -> PyResult<PyDataFrame> {
let df = CsvReadOptions::default()
.try_into_reader_with_file_path(Some(filepath.into()))
.unwrap()
.finish()
.unwrap();
// let df = {
// some work on the dataframe here
// todo!()
// };
println!(df ==>{}, df)
Ok(PyDataFrame(df))
}
#[pymodule]
fn rust_modules(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(polars_modules::read_file, m)?)?;
Ok(())
}
###This My Python Code
import rust_modules
import polars as pl
pg=rust_modules.read_file("/home/code/rust_modules/src/data/path.csv")
print(f"pfg >>> {pg}")
The Error That I am Getting
thread '<unnamed>' panicked at /home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-polars-0.18.0/src/types.rs:296:57:
called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'AttributeError'>, value: AttributeError("type object 'pyarrow.lib.Array' has no attribute '_import_arrow_from_c'"), traceback: None }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/home/code/rust_modules/test2.py", line 9, in <module>
pg=rust_modules.read_file("/home/code/rust_modules/src/data/path.csv")
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: PyErr { type: <class 'AttributeError'>, value: AttributeError("type object 'pyarrow.lib.Array' has no attribute '_import_arrow_from_c'"), traceback: None }`
This is my cargo.toml file
[package]
name = "rust_modules"
version = "0.1.0"
edition = "2021"
[lib]
name = "rust_modules"
crate-type = ["cdylib"]
[dependencies]
log = "0.4.22"
polars = "0.44.2"
pyo3 = { version = "0.21.0", features = ["extension-module"] }
pyo3-polars = "0.18.0"
I have tried uninstalling as well as installing pyarrow
My work Enviornment is Ubuntu 20.04.5 LTS x86_64
I have Python Packages
polars 0.18.15
pyarrow 18.0.0
numpy 1.26.4
Please Help
The text was updated successfully, but these errors were encountered:
Hello I am a beginner in Rust while exploring with Polars dataframe in rust I encountored an error where I am not able to transfer my dataframe from rust to python
This is My Rust Code
###This My Python Code
The Error That I am Getting
This is my cargo.toml file
I have tried uninstalling as well as installing pyarrow
My work Enviornment is Ubuntu 20.04.5 LTS x86_64
I have Python Packages
polars 0.18.15
pyarrow 18.0.0
numpy 1.26.4
Please Help
The text was updated successfully, but these errors were encountered: