Take every nth row on LazyFrame

55 Views Asked by At

I'm looking for the rust polars equivalent of the take_every function that is available for LazyFrames on python polars.

I want to determine the length of a LazyFrame and decimate it to less than n rows by skipping rows.

1

There are 1 best solutions below

0
On BEST ANSWER

Series has take_every(), you can use it as follows:

fn take_every(lazy_frame: LazyFrame, n: usize) -> LazyFrame {
    lazy_frame.select(&[col("*").map(move |s| Ok(Some(s.take_every(n))), GetOutput::same_type())])
}