import pandas as pd
dfs = pd.read_excel("工作表.xlsx", sheet_name=None)
# 添加新列
for df in dfs.values():
df.insert(9, "错误个数", pd.Series(), allow_duplicates=False)
# 计算个数
for df in dfs.values():
row_count_list = []
for index,row in df.iterrows():
count = 0
for item in row:
if type(item) == str:
if '关键字' in item:
count = count + 1
elif '关键字' in item:
count = count + 1
row_count_list.append(count)
df['错误个数'] = row_count_list
标签:count,对行,df,dfs,item,过滤,pd,pandas,row
From: https://www.cnblogs.com/tiansz/p/16824912.html