-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Allow Keyword Aggregation in DataFrame.agg and Series.agg #26513
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
Is this a blocker for 0.25.0? Is anyone interested in working on it? I'm not. cc @zertin, @smcateer, @pirsquared, who seemed interested in this for the GroupBy.agg context (this is for DataFrame/Series.agg). |
I am not sure what this follow-up corresponds to. As blocker, I remember the multiple lambda problem, for which I believe you said you had a WIP. Which of the blocker remaining issues this issue corresponds to? The description is unclear to me. |
Multiple lambdas is at #26905 (tagged for 0.25, but needs review). This issue is about supporting the new named aggregation syntax in DataFrame.agg, rather than just DataFrameGroupBy.agg (likewise for Series). Ideally, these two wouldn't diverge in behavior. In [2]: df = pd.DataFrame({"A": [1, 2, 1, 2], "B": [1, 2, 3, 4]})
In [3]: df
Out[3]:
A B
0 1 1
1 2 2
2 1 3
3 2 4
In [4]: df.agg(foo=("B", "sum"))
B
foo 10 |
Would be nice for 0.25, but not a blocker. Pushing. |
@TomAugspurger I'm going to look into this, just had a question about desired behavior. Currently, if you aggregate different functions on different series with In [16]: df = pd.DataFrame({"A": [1, 2, 1, 2], "B": [1, 2, 3, 4]})
In [17]: df
Out[17]:
A B
0 1 1
1 2 2
2 1 3
3 2 4
In [18]: df.agg({"A": "sum", "B": "mean"})
Out[18]:
A 6.0
B 2.5
dtype: float64 For the example you provided above, it would seem the result would be something like: In [18]: df.agg(foo=("A", "sum"), bar=("B", "mean"))
Out[18]:
A B
foo 6 NaN
bar NaN 2.5 When something like:
Would be the closest to current behavior. Any thoughts? |
You're probably right about the expected output being a Series there. |
Followup to #26399
Expected Output
without the warning. Similar for
Series.agg
The text was updated successfully, but these errors were encountered: