python小知识点 - 一个特殊小场景计数

(仅供参考,供复习学习使用)
背景是有一个表格table,统计非零值列数。

a b c d Count
0 1 4 0 2
1 0 3 6 3
0 1 1 12 3
table['Count']=0
for i in range(0,table.shape[0]):
	for j in range(0,table.shape[1]-1):
		if table[i,j]==0:
			table.loc[i,'Count'] += 1

猜你喜欢

转载自blog.csdn.net/qq_43165880/article/details/107947183