Skip to content
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

Single column groupby does not set name #358

Closed
wesm opened this issue Nov 10, 2011 · 0 comments
Closed

Single column groupby does not set name #358

wesm opened this issue Nov 10, 2011 · 0 comments
Labels
Milestone

Comments

@wesm
Copy link
Member

wesm commented Nov 10, 2011

In [2]: paste
df = DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
                                    'foo', 'bar', 'foo', 'foo'],
                             'B' : ['one', 'one', 'two', 'three',
                                    'two', 'two', 'one', 'three'],
                             'C' : np.random.randn(8),
                             'D' : np.random.randn(8)})
## -- End pasted text --

In [3]: df
Out[3]: 
   A    B      C        D     
0  foo  one   -2.096    0.4961
1  bar  one   -0.8738  -1.074 
2  foo  two   -0.01376 -0.956 
3  bar  three  0.996    0.368 
4  foo  two   -1.396   -0.3736
5  bar  two    0.7779   0.4091
6  foo  one   -0.1221   1.26  
7  foo  three -0.9718  -0.4734

In [4]: df.groupby('A').mean()
Out[4]: 
     C       D      
bar  0.3001 -0.09914
foo -0.9199 -0.00939

In [5]: df.groupby(['A', 'B']).mean()
Out[5]: 
           C       D     
A   B                    
bar one   -0.8738 -1.074 
    three  0.996   0.368 
    two    0.7779  0.4091
foo one   -1.109   0.878 
    three -0.9718 -0.4734
    two   -0.7048 -0.6648
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant