fileName = file_name
csvfile = open(fileName , 'rb') # 打开csv文件
reader = pd.read_csv(csvfile) # 读取文件内容
# print(reader['label'].value_counts())
aps = reader['label'].value_counts()
one = (aps== 1) ###
# print(aps[one])
reader = reader[(~reader['label'].isin(list(aps[one].index)))]
# print(reader['U_CODE'].value_counts())
reader.to_csv(outputFile,index=0)
python 去掉只出现一次的类别
最新推荐文章于 2024-05-14 11:00:23 发布