-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
A-apiArea: changes to the public APIArea: changes to the public APIacceptedReady for implementationReady for implementationenhancementNew feature or an improvement of an existing featureNew feature or an improvement of an existing feature
Description
Description
I recently came across the need to filter groups by some condition and was surprised to find that polars does not natively support this.
Currently, one has to do something like the following to filter for groups that satisfy a particular property:
df
.group_by("col")
.agg(at_least_two=pl.len() >= 2)
.filter("at_least_two")
.drop("at_least_two")
This would be much more ergonomic if there was a SQL-like having
construct:
df
.group_by("col")
.having(pl.len() >= 2)
While I personally like having as it distinguishes the context from the filter
method, pandas calls such a method filter
(docs).
Would you be open to adding something like this to polars?
lmocsi, mcrumiller, Object905, KronosTheLate and HansBambel
Metadata
Metadata
Assignees
Labels
A-apiArea: changes to the public APIArea: changes to the public APIacceptedReady for implementationReady for implementationenhancementNew feature or an improvement of an existing featureNew feature or an improvement of an existing feature