this has been a major challenge for me the past 2 days.
I would like to make a copy of df2 and create a new column that has the the df1['Forecast'] values in wherever df2['Material'] matches with df1['Material'].
df1=
| Material | Forecast |
|---|---|
| A1 | 30 |
| B1 | 23 |
| C1 | 50 |
df2=
| Material | Component | Quantity |
|---|---|---|
| A1 | 1 | 100.5 |
| B1 | 1 | 200.1 |
| B1 | 2 | 300.5 |
| A1 | 3 | 200.2 |
| B1 | 3 | 200.6 |
| C1 | 3 | 200.0 |
Final product would look something like this:
| Material | Component | Quantity | Forecast |
|---|---|---|---|
| A1 | 1 | 100.5 | 30 |
| B1 | 1 | 200.1 | 23 |
| B1 | 2 | 300.5 | 23 |
| A1 | 3 | 200.2 | 30 |
| B1 | 3 | 200.6 | 23 |
| C1 | 3 | 200.0 | 50 |
I tried creating dictionaries for both df's and iterating through both of them & I also tried creating lists and zipping them. I couldn't figure out how to get the desired final product. What is the best method for this?
Thank you so very much!