I need to make a function, which takes input as dataframe, and dictionary{"Col_2":% change,"Col_3":% change} and it should make the changes to the dataframe.
I Have data frame like this
| Date | col_1 | col_2 | col_3 |
|---|---|---|---|
| 01/01/2022 | 90 | 100 | 300 |
| 01/02/2022 | 80 | 110 | 310 |
| 01/03/2022 | 92 | 120 | 400 |
| 01/04/2022 | 96 | 130 | 300 |
| 01/05/2022 | 99 | 150 | 500 |
| 01/06/2022 | 105 | 155 | 600 |
Now I pass the dictionary say,
{"col_2":-10,"col_3":10}
Then my desired out would look like this
| Date | col_1 | col_2 | col_3 |
|---|---|---|---|
| 01/01/2022 | 90 | 90 | 330 |
| 01/02/2022 | 80 | 99 | 341 |
| 01/03/2022 | 92 | 108 | 440 |
| 01/04/2022 | 96 | 113 | 330 |
| 01/05/2022 | 99 | 135 | 550 |
| 01/06/2022 | 105 | 139.5 | 660 |
I followed this code(but didn't get my desired result)
def per_change(df,col,per):
m = 1+per/100
df['col_2'] *= m
return df