我有两个dataframes:如果在另一个数据框中存在相同的行,如何删除Pandas数据框中的行?
df1 = row1;row2;row3
df2 = row4;row5;row6;row2
我希望我的输出数据帧只包含在DF1独特的行,即:
df_out = row1;row3
我如何获得这个最有效的?
此代码我想要做什么,但使用2 for循环:
a = pd.DataFrame({0:[1,2,3],1:[10,20,30]})
b = pd.DataFrame({0:[0,1,2,3],1:[0,1,20,3]})
match_ident = []
for i in range(0,len(a)):
found=False
for j in range(0,len(b)):
if a[0][i]==b[0][j]:
if a[1][i]==b[1][j]:
found=True
match_ident.append(not(found))
a = a[match_ident]
没有重复,因为我没有映射到两个数据框中的公共值的唯一标识。 – RRC
不能标记它,但https://stackoverflow.com/questions/28901683/pandas-get-rows-which-are-not-in-other-dataframe – victor