原始数据:
处理后:
解决方案:
import pandas as pd
import os
import csv
path = r"D:\xxx\数据"
for dirpath,dirnames,filenames in os.walk(path):
for filename in filenames:
# 使用pandas读入
data = pd.read_csv(os.path.join(dirpath,filename)) #读取文件中所有数据
x = data[['x','y','z']]#读取x,y,z列
print(x)
a=x.drop_duplicates(subset=['x','y','z'],keep='first', inplace=False) #去重
print(a)
a.to_csv(r'./userid.csv',sep=",")#储存为新的文件,userid.csv:为文件名
版权声明:本文为weixin_61745097原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。