-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: named agg with multiple columns #37627
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
ENH: named agg with multiple columns #37627
Conversation
pls add tests always in fact tests should be done before any code changes to make sure they behave properly |
Thanks for the heads up @jreback , actually I was hoping to get some feedback which was the reason I pushed this as a draft while developing to get some comments. Some parts are challenging since I am not sure if I make the right decisions. |
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.
Can you add the test based on the example in the issue #29268 where you demonstrated aggregation a.max() - b.max()
?
This will be a good starting point for testing.
Then we can think of covering edge cases.
pandas/core/aggregation.py
Outdated
if is_list_like(k): | ||
for c in k: | ||
if c not in selected_obj.columns: | ||
raise KeyError(f"Column '{c}' does not exist!") |
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.
Should probably have else clause.
else:
raise KeyError(f"Column '{k}' does not exist!")
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.
Yes, good point, added. Thanks.
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.
What would you think of :
not_found = [c for c in k if c not in selected_obj.columns]
raise KeyError(f"Column(s) {', '.join(not_found)} do(es) not exist!")
Hello @erfannariman! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-09-12 11:44:58 UTC |
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
@erfannariman status here? |
This went stale, but is definitely one I would like very much to finish. I just think it gets quite complex on some points where I could use some guidance. Will take asap to clean up, merge master etc so it's updated. |
@erfannariman Can you merge master/update? Thanks. |
Thanks @erfannariman for the PR. closing as stale. ping if you want to continue. |
Started to work on this PR again, can you re-open? Thanks @simonjayhawkins |
this is quite old, happen to reopen if actively worked on. |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff