-
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
Create a separate class RollingGroupBy
#694
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, could you add as_polars_df.RPolarsRollingGroupBy
?
I was thinking that it would be better to make the contents of |
Co-authored-by: eitsupi <50911393+eitsupi@users.noreply.github.com>
I think the way I did it here matches quite well the python implementation: https://github.com/pola-rs/polars/blob/837ff46d2fb7435f3110e15b025af985bb5b6c8a/py-polars/polars/dataframe/group_by.py#L35 Since |
I don't think it is a big deal because basically the GroupBy class object is not intended to be used alone. |
We need to store the info (e.g groups) for when we print a |
Frankly, I don't see the need for this - could there be a situation where a GroupBy object could be printed as is without aggregation? |
Same argument for |
In fact ungroup does not exist in Rust and Python. I too think this can be removed. My basic idea is that there is no need for there to be a GroupBy object itself (for the same reason that Hadley regrets implementing dplyr's group_by as a stand-alone function). |
Agreed on this. I thought maybe I was missing something when |
I think ungroup is basically unnecessary, but since the operation is irreversible when GroupBy is created, there is a slight possibility that it could be used like undo if the user accidentally presses Enter in an interactive session. |
@etiennebacher Sorry, I was completely mistaken. I read the source code you linked to and Python has RollingGroupBy and DynamicGroupBy separately. |
Oh I thought the discussion above was simply about the |
Yes, I had assumed that only the GroupBy class existed in Python and was concerned that a completely unique class would be introduced here. But in fact this is a copy of Python, so the implementation makes sense. (I'm not a big fan of the way Polars does aggregate calculations, which is reinforced now that I know that LazyFrame and DataFrame have different classes returned by rolling, but that's just my preference). |
While reading the Rust source code, I noticed that aggregate calculation with GroupBy has been deprecated for years (pola-rs/polars#4946). |
Split the
GroupBy
andRollingGroupBy
implementations. This will make it easier to handle the variants ofGroupBy
(likeDynamicGroupBy
in #691).Note that
<LazyFrame>$rolling()
directly returns aLazyGroupBy
object from the Rust method. Should we manually change the class toLazyRollingGroupBy
? I don't really see the need for this since the "internals are opaque", but maybe you have an idea about that @eitsupi ?To be merged before #691