我需要计算每行中大于零的值的数量,并将它们存储在一个新列中
df波纹管如下所示:
team goals goals_against games_in_domestic_league
0 juventus 1 0 0
1 barcelona 0 1 1
2 santos 2 1 2
应成为:
team goals goals_against games_in_domestic_league total
0 juventus 1 0 0 1
1 barcelona 0 1 1 2
2 santos 2 1 2 3
Tags:
另一种选择是应用lambda,以便:
预期结果:
第一个想法是选择数字列,测试是否更大,如
0
,并按sum
计数True
:如果要按列表指定列,请执行以下操作:
相关问题 更多 >
编程相关推荐