I am trying to elaborate a df based on some of its columns (col1-4 herein), and to add a new column based on certain conditions defined in a function. The code might be clearer than an explanation in plain english:
def get_new_col(df):
    if (df['col1'] == 0) | (df['col2'] == 0):
        first_half = 0
    else:
        first_half = min(df['col1'], df['col2'])
    if (df['col3'] == 0) | (df['col4'] == 0):
        second_half = 0 
    else:
        second_half = min(df['col3'], df['col4'])
    return first_half + second_half
df['new_col'] = get_new_col(df)
My problem is that I am getting a ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()., even though I am properly (I think?) bracketing the conditions of the if statements and using the bitwise operator | instead of or, as suggested in this other thread.
Any idea on how to solve this?
 
     
    