Questions tagged [rust-polars]
271 questions
2
votes
1 answer
I just want to plot using Plotters data from a Polars dataframe in rust
I just want to plot data from a Polars datafram into a plotters image. I need help. I followed Iterate over rows polars rust to have this :
let iters = dataset
.columns(["x", "y"])?
.iter()
.map(|s| Ok(s.f64()?.into_iter()))
…

Bob Parker
- 99
- 7
2
votes
1 answer
Find unique intersection of a Series of lists of string
How do I find the set intersection of a column of lists?
[dependencies]
polars = { version = "*", features = ["lazy"] }
use polars::df;
use polars::prelude::*;
fn main() {
let df = df
jharting
- 71
- 3
2
votes
1 answer
Polars Rust melt() significantly slower than R stack()
I have some R code that takes a wide data.frame and stacks it into a narrow one. I rewrote this in Rust, but am finding it to be painfully slow. I am wondering if I am using bad practice or something here that is killing speed.
Original R…

Jage
- 453
- 2
- 9
2
votes
1 answer
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…

Rick Kim
- 21
- 2
2
votes
0 answers
How do I partition on saving parquet files with polars using Rust?
So I was able to save some struct to Parquet file using the following code:
pub fn store(data: Vec) -> () {
let json = serde_json::to_string(&data).unwrap();
let cursor = Cursor::new(json);
let mut df: DataFrame =…

Finlay Weber
- 2,989
- 3
- 17
- 37
2
votes
1 answer
Rust Polars WebAssembly CSVReader
I am having an issue below when trying to upload a CSV file and parse it in web assembly polars using rust.
Thanks
Error:
Grid.js:498 panicked at 'unsafe precondition(s) violated: ptr::read requires that the pointer argument is aligned and…

lallma
- 31
- 2
2
votes
1 answer
Selecting with Indexing is an anti-pattern in Polars: How to parse and transform (select/filter?) a CSV that seems to require so?
I would like to read the following (quite broken, IMO) CSV with Pola-rs, coming from a Rigol MSO5000 oscilloscope:
D7-D0,D15-D8,t0 = -25.01s, tInc =…

brainstorm
- 720
- 7
- 24
2
votes
1 answer
Resample time series using Polars in Rust
I'm trying to learn rust by doing some data parsing and re-work some of my trading tools but got stuck pretty quick.
I want to resample my data from 5 min to 15 min and Polars seems to be able to do this in an optimized way.
This is my try so far. I…

nklsla
- 315
- 1
- 9
2
votes
2 answers
How to efficiently create an index-like Polars DataFrame from multiple sparse series?
I would like to create a DataFrame that has an "index" (integer) from a number of (sparse) Series, where the index (or primary key) is NOT necessarily consecutive integers. Each Series is like a vector of (index, value) tuple or {index: value}…

Jongwook Choi
- 8,171
- 3
- 25
- 22
2
votes
1 answer
Two lists in a list of struct in Polars
I'm really new to Polars.
After running this code
fn read_csv() -> Result<(), PolarsError> {
println!("Hello, polars! ");
let df = CsvReader::from_path("./test_data/tar-data/csv/unziped/body.csv")?
.has_header(false)
…

Alexey
- 645
- 6
- 21
2
votes
0 answers
How to populate a Dataframe with struct elements ... and how to access them afterwards
Looking for help populating and using structs within a polars Dataframe/Series.
I know there is a JSON workaround to get structs into the df... but there should be a more straight forward solution rather than this "awkward" workaround?!
Once the…

Robert
- 131
- 1
- 7
2
votes
1 answer
Polars Rust: Read json file like Data Fusion or Spark?
How can I read a JSON file with polars, with the following format:
{},
{}
I can read the same file in DataFusion as follows:
#[tokio::main]
async fn main() -> datafusion::error::Result<()> {
env_logger::init();
let…

DataPsycho
- 958
- 1
- 8
- 28
2
votes
2 answers
use of undeclared type `ParquetWriter`
This seems very simple, but I don't understand ...
use polars::prelude::*;
use std::fs::File;
fn write_df_to_parquet(df: &mut DataFrame) {
let mut file = File::create("df.parquet").expect("could not create file");
ParquetWriter::new(&mut…

m_fmi
- 21
- 1
2
votes
1 answer
List of structs in (Rust) Polars column
Let's say I have a Polars column of type list[list[str]]:
Foos
---
list[list[str]]
[["a", "b"], ["c", "d"], ["e", "f"]]
[["g", "h"], ["i", "j"], ["k", "l"]]
[["m", "n"], ["o", "p"], ["q", "r"]]
...
and a struct Foo:
struct Foo {
f1: &str,
…

Neotenic Primate
- 313
- 3
- 13
2
votes
1 answer
Polars Dataframe- Remove duplicate rows based on one column
I would like to only include unique values in my polars Dataframe, based on one column.
In the example below I would like to create a new dataframe with only uniques based on the "col_float"…

wilaq
- 51
- 6