Home > Software design >  Concat or Merge Two Data Frames with same values
Concat or Merge Two Data Frames with same values

Time:10-06

Here is the first table(DataFrame) which has the 'sender' column with the value of 79

And Here is the Second table(DataFrame) which has the 'id' column as first column and written with departments,age of employee etc.

And here is my desired output for these two dataframes

My goal is merge or concat two dataframes, sender is a employee id of which sends the message and on employee table it is involved the personal information of employees. At the and I want to call and concatenate message senders with his/her personal info like in the third image. Thank you so much from now.

CodePudding user response:

Try to write your dfs instead of uploading images. Anyhow, considering df1 your first df and df2 the second:

df1 = df1.merge(df2, left_on='sender',right_on='id', how='left')
  • Related