pandas 遍历与组合筛选
import pandas as pd
from pandas import DataFrame
aa = [[1,4,5,7],
[2,4,6,8],
[5,6,9,1]]
# 列名
colu=['a','b','c','d']
# 行名称、索引
ind = [0,1,2]
test = DataFrame(data = aa,index = ind,columns=colu)
print(test.info())
# 遍历DataFrame,从而进行条件判断
for num in range(0,len(test)):
knn = test.loc[num][-1]
lr = test.loc[num][-2]
rs = test.loc[num][-3]
svm = test.loc[num][-4]
if knn+lr+rs +svm <19:
test.drop(test.index[num],inplace = True)
print(test)
test.to_csv("test02.csv",index = None)