This is my pandas dataframe, I have to calculate the weight in a new column 'Value.
For example, if the combination of columns (col1 col2 col3 col4) is 'Right_Wrong_Wrong_Right', then 'value' equals the product of weight, the total value should be 5 x 100 x 100 x 100 = 5,000,000.
I can't think of any ways that will allow me to map the rules to calculate the product of the weight if not hard code.
Something like this should work, although I can't really test it since you posted your dataframe as an image rather than as text.
The right half of the dataframe is preprocessed into a python dict
weightsthat maps each quadruple ('from', 'to', 'from_answer', 'to_answer') to the corresponding weight.This dict is used to write a function
get_valuethat can be used to calculate the value of each row.You can apply this function to the dataframe using
.apply(get_value, axis=1).