-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Groupby Agg not working if different partials with same name on the same column #28570
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
Comments
This works fine for me: from functools import partial
import pandas as pd
import numpy as np
quant50 = partial(np.percentile, q=50)
quant50.__name__ = "quant50"
quant70 = partial(np.percentile, q=70)
quant70.__name__ = "quant70"
test = pd.DataFrame({'col1': ['a', 'a', 'b', 'b', 'b'], 'col2': [1,2,3,4,5]})
test.groupby('col1').agg({'col2': [quant50, quant70]}) Out[110]:
col2
quant50 quant70
col1
a 1.5 1.7
b 4.0 4.4 Output of
|
take |
4 tasks
I view specifying the @mroeschke for any thoughts. |
That's a good point. Agreed it probably doesn't fix the original naming issue. |
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
related to #28426 from PR #28428
from functools import partial
import pandas as pd
import numpy as np
quant50 = partial(np.percentile, q=50)
quant70 = partial(np.percentile, q=70)
test = pd.DataFrame({'col1': ['a', 'a', 'b', 'b', 'b'], 'col2': [1,2,3,4,5]})
test.groupby('col1').agg({'col2': [quant50, quant70]})
However, quant50 result is rewritten by quant70, so will get the same output on both columns.
output:
expected output:
The text was updated successfully, but these errors were encountered: