vendredi 2 août 2019

If-else ValueError The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

I am trying to fill the missing values using if-else condition but getting the value error How can I resolve? I read another similar post but couldn't apply to my problem

I have tried if-else (value error) and also, iterate through indexing using for loop

When using for loop, it runs all rows through only if statement, and not going to else

Only if else statement(Value error)

if data['Waiting Time'] > 0:
    data['Existing_Date'].fillna(data['New_time'],inplace=True) #if wait_time > 0         
else:
    data['Existing_Date'].fillna(data['Actual Date'],inplace=True) #if wait_time > 0

Using For-loop indexing(only running if statement )

for i in data.index:
    if data['Waiting Time'].iloc[i] > 0:
        data['Existing_Date'].fillna(data['New_time'],inplace=True) #if wait_time > 0    
    else:
        data['Existing_Date'].fillna(data['Actual Date'],inplace=True) #if wait_time = 0

With if only statement Value error

with for loop: only result in if statement, not going to else statement

How can I solve this? Thanks

Aucun commentaire:

Enregistrer un commentaire