I have 2 data frames:
df1 has id and number of white products
product_id, count_white
12345,4
23456,7
34567,1
df2 has identifiers and counts of all products
product_id,total_count
0009878,14
7862345,20
12345,10
456346,40
23456,30
0987352,10
34567,90
df2 has more products than df1. I need to find df2 for products located in df1 and add the column total_count to df1:
product_id,count_white,total_count
12345,4,10
23456,7,30
34567,1,90
I could do a left merge, but I would get a huge file. Is there a way to add specific rows from df2 to df1 using merge?
source
share