import pandas as pd
file = pd.read_csv('in.csv',encoding='utf-8')
print(file.shape) # 输出原始数据的行和列
aa = []
f1 = open("yuan.txt","r",encoding="utf-8")
for l1 in f1.readlines():
l1 = l1.replace("\n","")
aa.append(l1)
delete_list = []
for i in range(0,file.shape[0]): # 遍历每一行
if file.iloc[i][1] not in aa:
delete_list.append(i) # 记录需要删除的行数
file = file.drop(delete_list) # 从原始数据里删除这些行
file.to_csv('out.csv', sep=',', header=True, index=True)
print(file.shape) # 输出处理后的行列数