I have two dataframes of different sizes, both have many columns and I need to compare two columns that have a different name and if there is a match then add the value of another column to a new column. This is like a VLOOKUP in excel, search the ID of the dataframe 1 in the company_id of dataframe 2 and if there are coincidences insert in the Qty value in the corresponding row of the dataframe 1
df1:
ID Area Dept
0 IDX1 A Dept 21
1 IDX2 B Dept 2
2 IDX3 C Dept 3
3 IDX4 D Dept 3
df2:
company_id Age Qty
0 ID01 42 10
1 IDX4 40 162
2 ID02 37 17
3 IDX1 42 100
4 ID24 40 12
5 IDX2 37 170
6 ID21 42 10
7 IDX3 40 120
8 ID02 37 17
this is the output that I need:
df3:
ID Area Dept extracted_qty
0 IDX1 A Dept 21 100
1 IDX2 B Dept 2 170
2 IDX3 C Dept 3 120
3 IDX4 D Dept 3 162