I want to merge the following two dataframes on their intersection on column 'Name'.
suppose dataframe 1 is:
Name subject_id Marks_scored
0 Billy sub1 98
1 Amy sub2 90
2 Bran sub4 87
3 Alice sub6 69
4 Ayoung sub5 78
and dataframe 2 is:
Name subject_id Marks_scored
0 Billy sub2 89
1 Brian sub4 80
2 Bran sub3 79
3 Bryce sub6 97
4 Betty sub5 88
I just want the output to be:
Name subject_id Marks_scored
0 Billy sub1 98
1 Bran sub4 87
2 Billy sub2 89
3 Bran sub3 79
pd.concat([df1, df2], axis=1, join='inner')
OR
pd.merge(df1, df2, on='subject_id', how='inner')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With