I have a dataframe DF1 which looks like this:
| Account Name | Task Type | Flag | Cost |
|---|---|---|---|
| Account 1 | Repair | True | $100 |
| Account 2 | Repair | True | $200 |
| Account 3 | Repair | False | $300 |
DF2 looks like this:
| Country | Percentage |
|---|---|
| US | 30% |
| Canada | 20% |
| India | 50% |
I want to create DF3 based on DF1 & DF2 by doing the following:
- Filter rows with where the Flag = True
- Create a new column 'Calculated_Cost' which will multiply the 'Cost' column in DF1 with percentage column of DF2 & create multiple rows based on the number of rows in DF2
The Final output would look like this:
| Account Name | Task Type | Flag | Cost | Country | Calculated_Cost |
|---|---|---|---|---|---|
| Account 1 | Repair | True | $100 | US | $30 |
| Account 1 | Repair | True | $100 | Canada | $20 |
| Account 1 | Repair | True | $100 | India | $50 |
| Account 2 | Repair | True | $200 | US | $60 |
| Account 2 | Repair | True | $200 | Canada | $40 |
| Account 2 | Repair | True | $200 | India | $100 |
| Account 3 | Repair | False | $300 | Nan | Nan |