[英]compare two seperate pandas dataframes row by row and return matching values
I have two pandas data frames df1 and df2.我有两个熊猫数据框 df1 和 df2。 df1 contains 2 columns and 750 rows, df2 has 2 columns and 88 rows.
df1 包含 2 列和 750 行,df2 包含 2 列和 88 行。 I want to compare the two data frames and return the values from df1 that are present in df2 and store the matching values in a new column in df2.
我想比较两个数据框并返回 df1 中存在于 df2 中的值,并将匹配值存储在 df2 中的新列中。 Ex.
前任。
df1
A B
emp_table emp_id
emp_table emp_name
pay_table basic_amount
pay_table da_amount
df2
A B
emp_table emp_id
emp_table emp_department
pay_table da_amount
I want to add another column in df2 which has the matching values.我想在 df2 中添加具有匹配值的另一列。
df2
A B
emp_table emp_id
pay_table da_amount
I want to perform one to many comparison of each element of df1 with each element of df2.我想对 df1 的每个元素与 df2 的每个元素进行一对多比较。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.