I have the following dataframe.
df
ID Q_code A_value B_value C_code Score
1 A_code 1 0 1 0.5
2 B_code 0 0 0 1
3 C_code 0 1 1 0
4 B_code 1 1 1 1
Based on ID and Q_code, for example under Q_code column for A_code and ID == 1 I would like to multiply, A_value X Score and update Score value. under Q_code column for B_code and ID == 2, I would like to multiply, B_value X Score and update Score value on that particular row. The same works for others.
ID Q_code A_value B_value C_code Score
1 A_code 1 0 1 0.5
2 B_code 0 0 0 0
3 C_code 0 1 1 0
4 B_code 1 1 1 1
I have tried this as follows but I would like to consider ID and Q_code
df['Score'] = df['A_value'] * df['Score']
Can any one help with this?