Pandas a beginning

from pandas import *
df = DataFrame({'key1' : ['a', 'a', 'b', 'b', 'a'],
'key2' : ['one', 'two', 'one', 'two', 'one'],
'data1' : np.random.randn(5),
'data2' : np.random.randn(5)})
df
data1 data2 key1 key2
0 0.012728 1.071175 a one
1 0.152258 0.246503 a two
2 -0.551473 1.101130 b one
3 0.392722 -0.919443 b two
4 -0.504487 0.385234 a one
grouped = df['data1'].groupby(df['key1'])
grouped.mean()
key1
a      -0.113167
b      -0.079376
Name: data1, dtype: float64