1diff_df = pd.merge(df1, df2, how='outer', indicator='Exist')
2
3diff_df = diff_df.loc[diff_df['Exist'] != 'both']
1source_df.merge(target_df,how='left',indicator=True).loc[lambda x:x['_merged']!='both']
1# by doing outer, you will get records from both the sides.
2f = df1.merge(df2,indicator = True, how='outer').loc[lambda x : x['_merge']!='both']
3Out[421]:
4 A B _merge
51 2 3 left_only
62 3 4 left_only
73 3 4 left_only
8
9left_unique_result = f.loc[lambda x: x['_merge'] == 'left_only']
10right_unique_result = f.loc[lambda x: x['_merge'] == 'right_only']