Questions tagged [rust-polars]
271 questions
0
votes
2 answers
thread '' panicked at assertion
I received an unknown error in Python Polars:
thread '' panicked at 'assertion failed: `(left == right)`
left: `Float64[NaN, 1, NaN, NaN, NaN, ...[clip]...
right: `Float64[NaN, 1, NaN, NaN, NaN, ...[clip]...
Is this an internal…

Test
- 962
- 9
- 26
0
votes
1 answer
how to cast a i64 Series/chunkedArray into f64 or String in polars-rust?
With a Series which comes from a column of DataFrame, how could cast it into a f64 Series or f64 ChunkedArray? It seems .apply_cast_numeric(|v| v as f64) got failure.

Hakase
- 211
- 1
- 12
0
votes
1 answer
Using polars’ query engine in wasm for a file loaded from the web-page
I am trying to implement a simple web app using a web assembly created with wasm-bindgen. I am entirely new to Rust.
The web page would have a file input element to select a CSV file. The web-assembly code would load this CSV and use polars to…

sovo2014
- 487
- 7
- 17
0
votes
2 answers
Use Groupby / Interpolate in Rust Polars
I'm working on a little utility app, coming from python/pandas and trying to rebuild some basic tools that can be distributed via executables. I'm having a hard time interpreting the documentation for what seems like it should be a fairly simple…

Eric O
- 171
- 1
- 9
0
votes
1 answer
Performance wise which is better - Dataframe Map vs Expression in Polars?
I am new to polar. I want to create a new column based on multiple columns. I could see that Expression is powerful but for complex logic it is quite difficult to interpret with case and when.
So I tried the map available in LazyFrame and it looks…

Selva
- 951
- 7
- 23
0
votes
1 answer
With Rust Polars, is there a good way to replace a specified value in a series like fill_null?
I have a dataset where null/missing values are represented by 0. So I'd like to do something like c.replace_val(0, "forward"). What is a good/easy/efficient way to do that? Thanks.

JulioBarros
- 43
- 1
- 5
0
votes
2 answers
Rust: Read dataframe in polars from mysql
Problem
How to read a dataframe in polars from mysql.
Docs are silent on the issue. Currently probably there is only support for parquet, json, ipc, etc, and no direct support for sql as mentioned here.
Regardless what would be an appropriate method…

Hamza Zubair
- 1,232
- 13
- 21
-1
votes
0 answers
How to access the groupBy key in Polars rust?
Assume we have a dataframe with columns A, B, C. I would like to group by column A and then refer to the value of column A in the apply function.
let groupby = df.groupby([col("A")]);
let agg_expr = as_struct(&[col("B"),…

kliao
- 549
- 1
- 6
- 14
-1
votes
0 answers
Populate a HashMap from data in Polars rust dataframe
What's the appropriate way to construct a HashMap from a Polars dataframe in rust? Looping through each row works but is too slow for my use case. Using the apply/map from the docs example, I was hoping to take advantage of the parallelization that…

kliao
- 549
- 1
- 6
- 14
-1
votes
0 answers
Reading file with polars and ignoring errors
I would like to read in a CSV file in polars using rust, and I would like to ignore all rows that cause an error. My understanding was that using with_ignore_errors(true) would skip the rows that cause error. However, I get an error.
use…

user22284368
- 1
- 2
-1
votes
2 answers
Polars: read from parquet in Rust
How do you read a parquet file into polars in Rust?
I am looking to read in from a parquet file into a polars object in rust and then iterate over each row.

Test
- 962
- 9
- 26
-1
votes
1 answer
Rust How to modify a polars DataFrame in a function, so that the caller see the changes?
I am lost at the mutable references ... Trying to send a DataFrame into a function ... change it and see the changes after the function call completes ...
I get error:
cannot borrow as mutable
Here is a code sample:
use polars::prelude::*;
use…

Robert
- 131
- 1
- 7
-1
votes
1 answer
Rust Polars feature select in Cargo.toml not working
I have a strange behavior. Apparently I must have messed up something:
My toml file:
[package]
name = "test"
version = "0.1.0"
edition = "2021"
[dependencies]
# Version 0.22.7 ==> works
polars = {version = "0.22.8", features = ["lazy"]}
# Version…

Robert
- 131
- 1
- 7
-1
votes
1 answer
ewm_mean ignore nan
Given a series with possible NaN values, how does one tell polars to ignore the NaN values? That is, treat the NaN value as if it weren't in the DataFrame, and use the same value for the mean as in the cell before the NaN value.
To be 100% specific,…

Test
- 962
- 9
- 26
-1
votes
1 answer
groupby_dynamic like method to support the interval index
something like a
#[derive(Clone, Debug)]
pub struct IntervalGroupOptions {
pub index_column: String,
/// start a window at this interval
pub every: i32,
/// window duration
pub period: i32,
/// offset window boundaries
…

yutiansut
- 11
- 5