Skip to content

API: consistency is return results of aggregation on SeriesGroupby #12334

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
jreback opened this issue Feb 15, 2016 · 0 comments
Closed

API: consistency is return results of aggregation on SeriesGroupby #12334

jreback opened this issue Feb 15, 2016 · 0 comments

Comments

@jreback
Copy link
Contributor

jreback commented Feb 15, 2016

xref 12329

For consistency, the proposal is to make [4] have a multi-level index ('C','sum'),('C','std') as its not a rename (like [5]). This previously raised in 0.17.1

In [2]: df = DataFrame({'A': ['foo', 'bar', 'foo', 'bar',
                              'foo', 'bar', 'foo', 'foo'],
                        'B': ['one', 'one', 'two', 'two',
                              'two', 'two', 'one', 'two'],
                        'C': np.random.randn(8) + 1.0,
                        'D': np.arange(8)})

In [3]: g = df.groupby(['A', 'B'])

In [4]: g['D'].agg({'C': ['sum', 'std']})
Out[4]: 
         sum       std
A   B                 
bar one    1       NaN
    two    8  1.414214
foo one    6  4.242641
    two   13  2.516611

In [5]: g['D'].agg({'C': 'sum', 'D' : 'std'})
Out[5]: 
          C         D
A   B                
bar one   1       NaN
    two   8  1.414214
foo one   6  4.242641
    two  13  2.516611
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant