"The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()" When trying to apply a function

I am encountering this error when trying to apply a function I have created. What is causing this?

def moonLight(moonPhase):
if 20 <= moonPhase > 10: 
    print(float(2)) 
elif moonPhase < 5:  
    print(float(0))
elif moonPhase > 25:
    print(float(0))
elif 10 <=  moonPhase < 0:  
    print(float(1))
elif 25 <= moonPhase < 20: 
    print(float(1))

calls['Light'] = moonLight(calls['Moon']) 
calls.head()


Read more here: https://stackoverflow.com/questions/68478758/the-truth-value-of-a-series-is-ambiguous-use-a-empty-a-bool-a-item-a-an

Content Attribution

This content was originally published by user15404111 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: