2016-04-16 19 views
0

DF ON:GROUP BY SUMパンダのデータフレーム

group each column based on class value and find the count, 
as in taking column 'a' as example the count should be 2 
for class '+' and 1 for class '-' 

コード:

grp = df.groupby(df.class, axis=1).sum() 

は私も理解しないエラーが発生して出力期待

a b class 
0 0 + 
0 1 + 
1 0 - 

。パンダには新しい、どんな提案も素晴らしいだろう。

+0

あなたは軸を指定する必要はありません。 – Alexander

答えて

1

これを試してみてください:

print(sample.groupby('class').count())