Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Python error: ValueError: The truth value of a Series is ambiguous

$
0
0

@Aarshay wrote:

Hi,

I'm trying to perform boolean indexing a series using values of other series of same length. This problem can be replicated using the code:

x = pd.Series([1,2,3])
y = pd.Series(x, copy=True)
print y[(x>1) or (x<=1)]

This results in an error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

If I use simply print x[x>1] it works fine. Not sure why it doesn't work with the "or" operator.

Please help.

Regards,
Aarshay

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles