I have two dataframes like this,
>>df1
name key1 key2 A B
0 a1 1 K0 A0 B0
1 a2 2 K1 A1 B1
2 a3 3 K0 A2 B2
3 a3 4 K1 A3 B3
>>df2
key1 key2
0 1 K0
1 2 K0
2 3 0K
3 4 1K
I need to compare key1,key2 of df1 with df2 and I have to print the matching rows. While comparing I have to check df1['key1','key2'] == df2['key1','key2'] or df1['key1','key2'] == df2['key1',reverse('key2')]
Expected Output:
>>df3
name key1 key2 A B
a1 1 K0 A0 B0
a3 3 K0 A2 B2
a3 4 K1 A3 B3
>>df4
name key1 key2 A B
a1 1 K0 A0 B0
a3 3,4 K0,K1 A2,A3 B2,B3