take union of two dataframes pandas
pd.concat([df1, df2])
4.13
8
m = {'left_only': 'df1', 'right_only': 'df2', 'both': 'df1, df2'}
result = df1.merge(df2, on=['A'], how='outer', indicator='B')
result['B'] = result['B'].map(m)
result
Thank you!
8
0
Are there any code examples left?
New code examples in category Python