RT,自己随便写了个,显示错误为ValueError: Can only compare identically-labeled DataFrame objects但总感觉思路都错了....请指教一下import pandas as pd
from pandas import DataFrame
L=[]
file=open('F:\\FCD\\实验文本.txt')
a=file.readlines()
for line in a:
L.append(line.split(','))
data=pd.DataFrame(L)
for i in range(len(data)):
for u in range(len(data)):
a=data[i:i+1]
b=data[u:u+1]
if u != i and a==b:
data.drop(data.index[[i,i+1]],inplace=True)
1 回答
largeQ
TA贡献2039条经验 获得超7个赞
import pandas as pd
from pandas import DataFrame
L=[]
file=open('F:\FCD\实验文本.txt')
a=file.readlines()
for line in a:
L.append(line.strip('\n'))
print L
data=pd.DataFrame(L)
print data
print len(data)
IsDuplicated = data.duplicated()
print IsDuplicated
print type(IsDuplicated)
data = data.drop_duplicates()
print data
你用这个试试
- 1 回答
- 0 关注
- 1561 浏览
添加回答
举报
0/150
提交
取消