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

Closed
jreback opened this Issue Feb 15, 2016 · 0 comments

Comments

Projects
None yet
1 participant
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

jreback added this to the 0.18.0 milestone Feb 15, 2016

@jreback jreback added a commit to jreback/pandas that referenced this issue Feb 17, 2016

@jreback jreback API: consistency in aggregate groupby results
closes #12334
522dd79

jreback closed this in 286d304 Feb 17, 2016

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