Skip to content

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

Closed
wants to merge 12 commits into from
Closed

ENH: named agg with multiple columns #37627

wants to merge 12 commits into from

Conversation

erfannariman
Copy link
Member

@erfannariman erfannariman marked this pull request as draft November 4, 2020 11:31
@jreback
Copy link
Contributor

jreback commented Nov 4, 2020

pls add tests always

in fact tests should be done before any code changes to make sure they behave properly

@erfannariman
Copy link
Member Author

erfannariman commented Nov 4, 2020

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.

Copy link
Member

@ivanovmg ivanovmg left a 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.

Comment on lines 730 to 733
if is_list_like(k):
for c in k:
if c not in selected_obj.columns:
raise KeyError(f"Column '{c}' does not exist!")
Copy link
Member

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!")

Copy link
Member Author

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.

Copy link
Member Author

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!")

@pep8speaks
Copy link

pep8speaks commented Nov 22, 2020

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

@erfannariman
Copy link
Member Author

@jreback @ivanovmg I made some progress, but I am at the point that I need to pass the DataFrame as a obj to the aggregator instead of a Series so we can do the aggregation over the columns.

@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Dec 23, 2020
@jreback
Copy link
Contributor

jreback commented Feb 11, 2021

@erfannariman status here?

@erfannariman
Copy link
Member Author

@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.

@lithomas1
Copy link
Member

@erfannariman Can you merge master/update? Thanks.

@simonjayhawkins
Copy link
Member

Thanks @erfannariman for the PR. closing as stale. ping if you want to continue.

@erfannariman
Copy link
Member Author

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

@simonjayhawkins simonjayhawkins added Apply Apply, Aggregate, Transform, Map Enhancement and removed Stale labels Sep 12, 2021
@jreback
Copy link
Contributor

jreback commented Nov 28, 2021

this is quite old, happen to reopen if actively worked on.

@jreback jreback closed this Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Enhancement Groupby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Named aggregations with multiple columns
6 participants