sbharti
New Contributor II

I think the best bet in such a case is to take inner join (equivalent to intersection) by putting a condition on those columns which necessarily need to have same value in both dataframes. For example,

let df1 and df2 are two dataframes. df1 has column (A,B,C) and df2 has columns (D,C,B), then you can create a new dataframe which would be the intersection of df1 and df2 conditioned on column B and C.

df3 = df1.join(df2, [df1.B == df2.B , df1.C == df2.C], how = 'inner' )

df3 will contain only those rows where the above condition is satisfied from df1 and df2.