0

Lets say I have a simple function like this:

def func(a,b):
    if a>b:
        return 1
    else:
        return 0

what I want to happen is when I feed lists like [1, 2, 3, 4, 5] and [-1, 3, -3, 5, -5] to it that it would return a list [1, 0, 1, 0, 1]. That doesnt't happen, it says "The truth value of a Series is ambiguous..." and that's understandable, inside of the function is compares whole lists, spits out a list of boolean values and that cannot be interpreted by if. Is there an elegant way of doing it without a loop?

0 Answers0