0

I want to merge the two data frames by their Id that is named differently in both data frame. I only want to take two columns which are the ItemBought and Price from the first df and merge it to the second df and place it in that manner. I have tried to rbind them, but I was not able to put it according to their Id.

first df

User_Id ItemBought Price
1 1003      Candy  1.50
2 1005   Beverage  2.00
3 1001  Ice-cream  1.25
4 1002     Burger  4.00
5 1004      Pizza 10.00

Second df

    Id  Name Membership
1 1001  John       Gold
2 1002  Adam     Silver
3 1003 Allan       Gold
4 1004 Peter     Bronze
5 1005  Neil     Silver

Desired Output:

    Id  Name  ItemBought  Price Membership
1 1001  John   Ice-cream   1.25       Gold
2 1002  Adam       Pizza  10.00     Silver
3 1003 Allan       Candy   1.50       Gold
4 1004 Peter    Beverage   2.00     Bronze
5 1005  Neil      Burger   4.00     Silver
High Low
  • 67
  • 6
  • 1
    Does this answer your question? [How to join (merge) data frames (inner, outer, left, right)](https://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right) – Stephan Sep 17 '20 at 06:24
  • Thank you! It does originally but I realised that the column Id name was different in the two data frame. – High Low Sep 17 '20 at 06:47

0 Answers0