简体   繁体   English

连接或合并两个具有相同值的数据框

[英]Concat or Merge Two Data Frames with same values

Here is the first table(DataFrame) which has the 'sender' column with the value of 79这是第一个表(DataFrame),其“发件人”列的值为 79

And Here is the Second table(DataFrame) which has the 'id' column as first column and written with departments,age of employee etc.这是第二个表(DataFrame),它的第一列是“id”列,并写有部门、员工年龄等。

And here is my desired output for these two dataframes这是我想要的这两个数据帧的 output

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.我的目标是合并或连接两个数据帧,发件人是发送消息的员工 ID,在员工表上涉及员工的个人信息。 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.从现在开始非常感谢你。

Try to write your dfs instead of uploading images.尝试编写您的 dfs 而不是上传图像。 Anyhow, considering df1 your first df and df2 the second:无论如何,考虑df1你的第一个 df 和df2第二个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 合并两个数据框并对列中的值求和 - Merge two data frames and summing the values in columns 合并多个值上的两个数据帧 - Merge two data frames on multiple values 当连接具有同一列的两个数据框时,更改列的级别 - change the level of a column, when concat two data frames with the same column 基于具有相同值对但在两个数据框中以不同顺序显示的两列合并熊猫数据框 - Merge pandas data frames based on two columns with the same pair of values but displayed in different orders in the two dataframes 如何在具有相似值(但不相同)的公共列上合并 Pandas 中的两个数据框? - How do I merge two data frames in pandas on a common column which have similar values (but not the same)? 如何根据一列中的相似值水平合并具有相同列名的两个数据框 - How to merge two data frames having same column names horizontally on basis of similar values in one column 如何使用 concat 或 merge 合并两个数据框? - How do I merge two data frames using either concat or merge? 如何在熊猫中合并具有重复值的两个数据框 - How to merge two data frames with repeated values in pandas 如何在不丢失值的情况下合并 Pandas 中的两个数据帧 - How to merge two data frames in Pandas without losing values pandas合并两个数据帧并汇总单元格值 - pandas merge two data frames and summarize cell values
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM