You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: