我在Spark中有两个数据帧。
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
您可以使用 exceptAll 作为
exceptAll
df3 = df1.select("C1").exceptAll(df2.select("C1")) result = df1.join(df3, df1.C1 == df3.C1).drop(df3.C1)