vendredi 29 décembre 2017

Python if statement error

very new Python user here with limited programming experience. I have the following code,

if df['one'] >= df['two'].shift(1) and df['three'] <= df['two'].shift(1) \
        and df['stdnormprob'] > trigger1 and df['stdev'] > trigger2:
    df['execution']=1
else:
    df['execution']=0

and I get the following error when I try to execute it,

line 1121, in __nonzero__
    .format(self.__class__.__name__))
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(),

a.item(), a.any() or a.all().

I'm not sure why this is occurring. The dataframe looks okay, with the exception that there are some Nan entries in there that I probably need to ignore. Any insight as to why this error is occurring would be much appreciated...Thank you!

Aucun commentaire:

Enregistrer un commentaire