Reputation: 1023
I have two Series which have a format equal to this:
0 False
1 False
2 False
3 True
4 True
Name: foo, dtype: bool
0 True
1 False
2 False
3 True
4 True
Name: bar, dtype: bool
I want to create a new Series with the resulting boolean comparison from these. Something like this:
result = foo and bar
>>> print result
0 False
1 False
2 False
3 True
4 True
Name: result, dtype: bool
Using the obvious result = foo and bar
simply results in the following error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I looked at those functions, but neither seem to do what I wish.
How can I do an element-to-element boolean comparison of a Series resulting in a new Series?
Upvotes: 11
Views: 14111