I have a data frame as follows;
return | Upper | lower |
---|---|---|
50 | 70 | 20 |
10 | 15 | 3 |
I'm trying to count how many times the return is in-between the upper and lower. I have tried to create another bool type column if the condition is true.
for val in data['return']:
if data['return'] < data['upper'] or data['return']> data['lower']:
data['Predicted'] = 1
else:
data['Predicted'] = 0
where data[predicted]
should be the new column.
However I get the error
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I have tried changing the operator to |
, but it didn't work. I'm new to python and are unsure what way to best solve this.
For context my goal is to calculated how many times it has predicted it right. I am not sure if this method is the best way.