I am trying to create calculated_field for every every month from Year 1 to Year 10 based on parameter values in Data Frame 1. From the dataframe given below we need create Data Frame 2 from Data Frame 1. Basically each id will have 120 rows( 12 months * 10 Years) and this needs to be done for thousands of unique id. What would be the best way to do this using What is the best way to do this in pandas with optimal runtime:-
Data Frame 1:-
| ID | VAR1 | VAR2 |
|---|---|---|
| 1 | ABC | XYZ |
| 2 | MNP | QRS |
| 3 | UVW | STU |
Data Frame 2:-
| ID | YEAR_MONTH | VAR1 | VAR2 | calculated_field |
|---|---|---|---|---|
| 1 | 1_1 | ABC | XYZ | 5 |
| 1 | 1_2 | ABC | XYZ | 6 |
| 1 | 1_3 | ABC | XYZ | 7 |
| 2 | 1_1 | MNP | QRS | 11 |
| 2 | 1_2 | MNP | QRS | 12 |
| 2 | 1_3 | MNP | QRS | 13 |
| 3 | 1_1 | UVW | STU | 43 |
| 3 | 1_2 | UVW | STU | 44 |
| 3 | 1_3 | UVW | STU | 45 |