-
Notifications
You must be signed in to change notification settings - Fork 140
feat: Allow expressions as group_by
keys
#2325
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
Conversation
https://github.com/narwhals-dev/narwhals/actions/runs/14204180755/job/39797880528?pr=2325
@FBruzzesi π I'll try taking a look soon UpdateAh the issue is |
@FBruzzesi for narwhals/narwhals/_polars/namespace.py Lines 54 to 55 in 4d2b9d5
They essentially need something like this, but I've been putting off doing it since they have waaaaaay more methods π narwhals/narwhals/_polars/dataframe.py Lines 59 to 85 in 4d2b9d5
|
group_by
keysgroup_by
keys
π¨ |
Resolves them depending on `list.copy` > Cannot access attribute "copy" for class "Sequence[str]" Attribute "copy" is unknown
This comment was marked as resolved.
This comment was marked as resolved.
- Don't use `pl.Expr` for `_keys` - We technically don't need that attribute for `polars` anyway - Use new `IncompletePolarsExpr` - Don't require `_parse_expr` for `Polars*` - It doesn't need that method - Still planning to change it later in (#2325 (comment))
Was needed earlier in the PR, but now unused
Ended up defining in `CompliantDataFrame` after
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.
Great work @FBruzzesi π
I've left some comments/suggestions, but nothing blocking.
This is an exciting step towards expressifying more of narwhals
π
Thanks @dangotbanned - I am a bit short on time this week and the next - so apologies for my slow feedback loop.
It definitly is - exciting times! |
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 again @FBruzzesi
I'll leave open until the end of the day in case @MarcoGorelli wants time chime in - but otherwise I'll merge later β€οΈ
thanks both, really amazing stuff! i'll just trying breaking this a bit more, then i'd say we can ship it |
@MarcoGorelli wanted to check in to see if you were okay with me merging? No worries at all if not! |
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.
I reverted a change to an existing test - in general i'd suggest to just add a new test if you're testing something different
For anything this close to the library core and to expression parsing, please do wait for me to take a final look
Anyway, this looks great, thanks @FBruzzesi and @dangotbanned ! You have a lot to be proud of here. I'm certainly proud that all together we've arrived at such a simple-looking solution
type checking does pass in CI, but there is the occasional squiggly line in vscode. happy to resolve that separately though
@MarcoGorelli would we be able to set up something to preserve co-authors? I think I'm missing again π |
ah so sorry π© π³ the combination of 124 commit messages was too long so i removed the whole thing, but it looks like i should've kept the "co-authored by" part at the end for co-authors to show up I'll be very careful to always do that in the future π |
What type of PR is this? (check all applicable)
Related issues
nw.col
/Expr
for.group_by
Β #1385Checklist
If you have comments or can explain your changes, please do so below
@MarcoGorelli there is one test failing - which is grouping by a pandas column with a boolean name (and similarly with integer name in scikit-lego)
@dangotbanned I am crying for help with the typing π
Other comment will address in the code itself