Based on this approach :
import pandas as pd
df1 = pd.DataFrame([[1,11, 111], [2,22, 222], [3, 33, 333]], columns=['A', 'B', 'C'])
df2 = pd.DataFrame([[1, 11]], columns=['A', 'B'])
Combine data:
df = pd.concat([df1, df2])
df.reset_index(drop=True)
Group the required comparison columns - in your case, A
and B
:
df_gpby = df.groupby(['A','B'])
Get codes for groups with one meaning - that is unique in pairs A
, B
:
idx = [x[0] for x in df_gpby.groups.values() if len(x) == 1]
Adjust concatenated index data frame:
df.iloc[idx]
Results in:
A B C
1 2 22 222
2 3 33 333