Hi All,
Could someone tell me why I'm getting the following error and how to fix it?
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
There was a runtime error on line 60.
Thanks,
Rohit
Hi All,
Could someone tell me why I'm getting the following error and how to fix it?
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
There was a runtime error on line 60.
Thanks,
Rohit
Your statements in lines 109 to 133 try to do a logical comparisons on 'context.X' and 'context.Y'. The problem is that these are pandas series objects and not simple real numbers. Not sure what you are trying to do but if you want to compare the latest value in each series you can use the [-1] index approach.
# Below the variables context.X and context.Y are series.
# Python doesn't understand how to compare series like this
if zscore >= 1.0:
if context.X > context.Y:
target_weights[x_contract] = -0.166
target_weights[y_contract] = 0.166
....
# If one wants to compare the last values in the series
# should maybe be something like this
if zscore >= 1.0:
if context.X[-1] > context.Y[-1]:
target_weights[x_contract] = -0.166
target_weights[y_contract] = 0.166