I would greatly appreciate any help. Within a dataframe, I have products that are grouped and scored according to their groups (group A products have the same set of Score_1, Score_2, ..., Score_N, Group B has another set etc). As some products/groups are referencing others, their scores need to be replaced with the scores of those groups that they are referencing. The Dataframe currently looks like this:
Product Group Reference_Group Score_1 Score_2 ... Score_N
0 XXX0X1 A NaN 0.007598 0.007538
1 XXX0X2 A NaN 0.007598 0.007538
2 XXX0X3 A NaN 0.007598 0.007538
3 XXX0X4 B A 0.003343 0.002696
4 XXX0X5 B A 0.003343 0.002696
5 XXX0X6 B A 0.003343 0.002696
6 XXX0X7 C NaN 0.003399 0.004444
7 XXX0X8 C NaN 0.003399 0.004444
8 XXX0X9 C NaN 0.003399 0.004444
9 XXX0X10 D C 0.006677 0.006262
10 XXX0X11 D C 0.006677 0.006262
11 XXX0X12 D C 0.006677 0.006262
...
1569
Where the Reference_Group != NaN, I need to replace the Score_1, Score_2, ..., Score_N of those rows with that of the Group indicated in Reference_Group (Score_1, Score_2, ..., Score_N for Group B products need to be replaced with Score_1, Score_2,..., Score_N of Group A products). The rows with NaN in Reference_Group need not be edited. The final df needs to look like this:
Product Group Reference_Group Score_1 Score_2 ... Score_N
0 XXX0X1 A NaN 0.007598 0.007538
1 XXX0X2 A NaN 0.007598 0.007538
2 XXX0X3 A NaN 0.007598 0.007538
3 XXX0X4 B A 0.007598 0.007538
4 XXX0X5 B A 0.007598 0.007538
5 XXX0X6 B A 0.007598 0.007538
6 XXX0X7 C NaN 0.003399 0.004444
7 XXX0X8 C NaN 0.003399 0.004444
8 XXX0X9 C NaN 0.003399 0.004444
9 XXX0X10 D C 0.003399 0.004444
10 XXX0X11 D C 0.003399 0.004444
11 XXX0X12 D C 0.003399 0.004444
...
1569
As there are too many rows and columns, I cannot hardcode for only the examples above.
Thank you for reading my question!