I have the following dataframe:
The dX_real refers to the actual values on day 3, day 7, and day 14… and the second one is each multiplier for that specific day.
I want to calculate those predictions in the following way. First, I take the target column (d3_real, d7_real…) and then I multiply it for each multiplier depending on the case. for example, to calculate the prediction from d3_real to d30, I would need to multiply it by the multipliers of D7, D14 and D30.
Is there any way to automate this with a loop? I do not know how to multiply each dX_real column without using conditional for each case as the number of multiplications changes.
This is what I have tried that it is not working as expected, as it is only multiplying the first multiplier:
However, from here, I do not know how to specific which values it needs to multiply based on d3, d7 and d14.
Here the first loop selects the names of the new columns from the ‘ddd’ list and sets the first value in the new column. In the nested loop, the numbers of the desired columns are taken from the list ‘bbb’ and the values are multiplied. Check with your data or show the expected result with your example. You need to check for a match.
If you have better answer, please add a comment about this, thank you!