ENH: Unify API of groupby.sum and sum
See original GitHub issueIs your feature request related to a problem?
The level keyword in sum is marked as deprecated, but the suggested replacement with groupby.sum
does not support skipna, therefore, some behaviours are impossible to replicate easily.
Describe the solution you’d like
grouby.sum
should accept the skipna=False keyword,
API breaking implications
Currently the API is inconsistent, since
df.sum(axis=1, level=0, skipna=False)
has no equivalent since df.groupby(axis=1, level=0).sum(skipna=False)
is not available.
Describe alternatives you’ve considered
One can of course do: df.groupby(axis=1, level=0).apply(lambda x : x.sum(axis=1, skipna=False))
but this cannot be the intended use.
Additional context
# Your code here, if applicable
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
ENH: Unify API of groupby.sum and sum - GitHub
Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, ...
Read more >Pandas groupby() and sum() With Examples
groupby () function returns a DataFrameGroupBy object which contains an aggregate function sum() to calculate a sum of a given column for each ......
Read more >pandas GroupBy columns with NaN (missing) values
with NA df.groupby('b', dropna=False).sum() a c b 1.0 2 3 2.0 2 5 NaN 1 4 ... merge unique index on dataframe...
Read more >Pandas Groupby and Sum - GeeksforGeeks
Here, we can apply a group on multiple columns and calculate a sum over each combination group. Python3. Python3 ...
Read more >Lodash Documentation
groupBy · _.includes · _.invokeMap · _.keyBy · _.map · _. ... minBy · _.multiply · _.round · _.subtract · _.sum · _.sumBy...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i am +1 in unifying signatures between aggregators
this is a footgun that we can easily prevent
being efficient for a non default keyword doesn’t matter that much. api consistency is much more important
the deprecation was discussed in #39983 and implemented in #40869 and introduced in pandas 1.3
the issue here has already been communicated (with a copy and paste-able code sample) in https://github.com/pandas-dev/pandas/issues/39983#issuecomment-916549939
It is too late now that we are on pandas 1.4.x to undo the deprecation until an appropriate less verbose alternative is available.
there is already an issue to enable skipna on groupby reduction ops #15675, so I think safe to close this as a duplicate.
@phil20686 Thanks for the report. please continue to contribute to the discussion at #15675 instead.