-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement $rolling()
for DataFrame
and LazyFrame
#682
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this.
I don't think this currently supports $ungroup()
. Need to add tests.
Also, rather than making the implementation of RPolarsGroupBy complicated like this, I thought it would be simpler and better to delete by_agg
on the Rust side and rewrite it to always call $lazy()
and $collect()
on the R side.
r-polars/src/rust/src/rdataframe/mod.rs
Lines 310 to 327 in ffc9a5c
//used in GroupBy, not DataFrame | |
pub fn by_agg( | |
&mut self, | |
group_exprs: Robj, | |
agg_exprs: Robj, | |
maintain_order: Robj, | |
) -> RResult<RPolarsDataFrame> { | |
let group_exprs: Vec<pl::Expr> = robj_to!(VecPLExprCol, group_exprs)?; | |
let agg_exprs: Vec<pl::Expr> = robj_to!(VecPLExprColNamed, agg_exprs)?; | |
let maintain_order = robj_to!(Option, bool, maintain_order)?.unwrap_or(false); | |
let lazy_df = self.clone().0.lazy(); | |
let lgb = if maintain_order { | |
lazy_df.group_by_stable(group_exprs) | |
} else { | |
lazy_df.group_by(group_exprs) | |
}; | |
RPolarsLazyFrame(lgb.agg(agg_exprs)).collect() | |
} |
I'll open a new PR for that as it touches the |
Of course it's okay. Thanks! |
Co-authored-by: eitsupi <50911393+eitsupi@users.noreply.github.com>
No description provided.