我在Spark中有2个数据框。
DF1:
c1,c2
a,1
b,2
c,3
DF2:
c1,c2
d,4
e,5
a,6
我想从DF1中选择所有记录,除了DF2中与C1列匹配的记录(值'a'在第二个数据帧中,因此需要从第一个数据帧中过滤掉记录)。
结果应为:
DF3:
c1,c2
b,2
c,3
答案 0 :(得分:1)
您可以将exceptAll
用作
df3 = df1.select("C1").exceptAll(df2.select("C1"))
result = df1.join(df3, df1.C1 == df3.C1).drop(df3.C1)