mardi 15 décembre 2020

The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all() error in a if statement

I'm trying to work these comand lines:

for lm_inf in df.columns:
    if df['a1'].astype('int64') > 0 & df['b1'].astype('int64') < 0:
         df['lm_inf'] == 0        
    elif df['a1'].astype('int64') > 0 & df['b1'].astype('int64') > 0:
        df['lm_inf'] == df['a1']
    elif df['a1'].astype('int64') < 0 & df['b1'].astype('int64') < 0:
        df['lm_inf'] == 0
    elif df['a1'].astype('int64') < 0 & df['b1'].astype('int64') > 0:
        df['lm_inf'] == 0
    else:
        df['lm_inf'] == 0  

But, they are not working. How can I rewrite the comand lines to solve this problem?

Aucun commentaire:

Enregistrer un commentaire