df:
a b class
0 0 +
0 1 +
1 0 -
预期输出:
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()
得到我什至不理解的错误。对熊猫来说是新手,任何建议都很棒。
试试这个:
print(sample.groupby('class').count())
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句