I have a dataframe like below. I want to update the value of column C,D, E based on column A and B.
If column A < B, then C, D, E = A, else B. I tried the below code but I'm getting ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). error
import pandas as pd
import math
import sys
import re
data=[[0,1,0,0, 0],
      [1,2,0,0,0],
      [2,0,0,0,0],
      [2,4,0,0,0],
      [1,8,0,0,0],
      [3,2, 0,0,0]]
df
Out[59]: 
   A  B  C  D  E
0  0  1  0  0  0
1  1  2  0  0  0
2  2  0  0  0  0
3  2  4  0  0  0
4  1  8  0  0  0
5  3  2  0  0  0
df = pd.DataFrame(data,columns=['A','B','C', 'D','E'])
list_1 = ['C', 'D', 'E']
for i in df[list_1]:
    if df['A'] < df['B']:
        df[i] = df['A']
    else:
        df['i'] = df['B']
I'm expecting below output:
df
Out[59]: 
   A  B  C  D  E
0  0  1  0  0  0
1  1  2  1  1  1
2  2  0  0  0  0
3  2  4  2  2  2
4  1  8  1  1  1
5  3  2  2  2  2
 
     
     
     
     
     
    