Skip to content

ENH: Named aggregation in SeriesGroupBy.agg #26580

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

Merged
merged 6 commits into from
Jun 10, 2019

Conversation

TomAugspurger
Copy link
Contributor

In [4]:    animals = pd.DataFrame({'kind': ['cat', 'dog', 'cat', 'dog'],
   ...:                            'height': [9.1, 6.0, 9.5, 34.0],
   ...:                            'weight': [7.9, 7.5, 9.9, 198.0]})
   ...:    animals.groupby("kind").height.agg(max_height='max')
Out[4]:
      max_height
kind
cat          9.5
dog         34.0

Closes #26512

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

```python
In [4]:    animals = pd.DataFrame({'kind': ['cat', 'dog', 'cat', 'dog'],
   ...:                            'height': [9.1, 6.0, 9.5, 34.0],
   ...:                            'weight': [7.9, 7.5, 9.9, 198.0]})
   ...:    animals.groupby("kind").height.agg(max_height='max')
Out[4]:
      max_height
kind
cat          9.5
dog         34.0
```

Closes pandas-dev#26512
@codecov
Copy link

codecov bot commented May 30, 2019

Codecov Report

Merging #26580 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26580      +/-   ##
==========================================
- Coverage   91.84%   91.84%   -0.01%     
==========================================
  Files         174      174              
  Lines       50643    50656      +13     
==========================================
+ Hits        46515    46524       +9     
- Misses       4128     4132       +4
Flag Coverage Δ
#multiple 90.38% <100%> (ø) ⬆️
#single 41.7% <7.14%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/core/groupby/generic.py 89.27% <100%> (+0.18%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 97% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a60d1bd...c008426. Read the comment docs.

@codecov
Copy link

codecov bot commented May 30, 2019

Codecov Report

Merging #26580 into master will decrease coverage by <.01%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26580      +/-   ##
==========================================
- Coverage   91.71%   91.71%   -0.01%     
==========================================
  Files         178      178              
  Lines       50740    50755      +15     
==========================================
+ Hits        46538    46548      +10     
- Misses       4202     4207       +5
Flag Coverage Δ
#multiple 90.3% <93.75%> (ø) ⬆️
#single 41.22% <6.25%> (-0.1%) ⬇️
Impacted Files Coverage Δ
pandas/core/groupby/generic.py 89.16% <93.75%> (+0.08%) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f3e8e8...8fe39f1. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comments

@@ -331,6 +331,37 @@ def test_uint64_type_handling(dtype, how):

class TestNamedAggregation:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could make this a separate class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're saying split the series specific ones, into TestNamedAggregationSeries and TestNamedAggregationDataFrame?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm ex @jreback comments

@jreback
Copy link
Contributor

jreback commented Jun 8, 2019

can you merge master to ensure passing, otherwise lgtm.

@TomAugspurger
Copy link
Contributor Author

All green.

@jreback jreback merged commit 5574a9f into pandas-dev:master Jun 10, 2019
@jreback
Copy link
Contributor

jreback commented Jun 10, 2019

thanks @TomAugspurger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Keyword aggregation in SeriesGroupBy
3 participants