I have a dataframe with three columns A, B and C. I have to create fourth column with the name "Differential_value". I have to assign values to this fourth column using some condition. The condition is as follows:
1) First condition: if any of the three columns A,B or C has 0 value, then the I have 0 in "Differential_value" column.
2) Otherwise,"Differential_value" assigned value should be:
(max(A,B,C) - min(A,B,C))/min(A,B,C)
Below is my sample data:
A B C
10 7 0
10 8 12
9 8 11
10 11 12
13 5 0
0 3 10
12 8 11
12 9 7
11 10 9
10 11 9
Below is my code that I have tried:
df['differential_value'] = np.where((df['A']==0)|(df['B']==0)|(df['C']== 0),0),(np.where((df[['A','B','C']].max() - df[['A','B','C']].min())/df[['A','B','C']].min()))
ValueError: either both or neither of x and y should be given