Sha256: 3af66e198c21176a3b96c9356bab3f754d24c86c1eb9bc442077055d5cb8bef3

Contents?: true

Size: 773 Bytes

Versions: 13

Compression:

Stored size: 773 Bytes

Contents

use magnus::RArray;
use polars::lazy::frame::LazyGroupBy;
use std::cell::RefCell;

use crate::expr::rb_exprs_to_exprs;
use crate::{RbLazyFrame, RbResult};

#[magnus::wrap(class = "Polars::RbLazyGroupBy")]
pub struct RbLazyGroupBy {
    pub lgb: RefCell<Option<LazyGroupBy>>,
}

impl RbLazyGroupBy {
    pub fn agg(&self, aggs: RArray) -> RbResult<RbLazyFrame> {
        let lgb = self.lgb.borrow_mut().take().unwrap();
        let aggs = rb_exprs_to_exprs(aggs)?;
        Ok(lgb.agg(aggs).into())
    }

    pub fn head(&self, n: usize) -> RbLazyFrame {
        let lgb = self.lgb.take().unwrap();
        lgb.head(Some(n)).into()
    }

    pub fn tail(&self, n: usize) -> RbLazyFrame {
        let lgb = self.lgb.take().unwrap();
        lgb.tail(Some(n)).into()
    }
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
polars-df-0.17.0 ext/polars/src/lazygroupby.rs
polars-df-0.16.0 ext/polars/src/lazygroupby.rs
polars-df-0.15.0 ext/polars/src/lazygroupby.rs
polars-df-0.14.0 ext/polars/src/lazygroupby.rs
polars-df-0.13.0 ext/polars/src/lazygroupby.rs
polars-df-0.12.0 ext/polars/src/lazygroupby.rs
polars-df-0.11.0 ext/polars/src/lazygroupby.rs
polars-df-0.10.0 ext/polars/src/lazygroupby.rs
polars-df-0.9.0 ext/polars/src/lazygroupby.rs
polars-df-0.8.0 ext/polars/src/lazygroupby.rs
polars-df-0.7.0 ext/polars/src/lazygroupby.rs
polars-df-0.6.0 ext/polars/src/lazygroupby.rs
polars-df-0.5.0 ext/polars/src/lazygroupby.rs