Reputation: 1
a=np.arange(1,10)
b=pd.Series(a)
print(a==b)
output: 0. True
but when I made it in a loop
if (a==b):
print('True')
output: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Upvotes: 0
Views: 140
Reputation: 71610
a==b
will give a Series, so if you want check if all the values are the same, try:
if (a==b).all():
print('True')
If you want to check if any of the values are the same:
if (a==b).any():
print('True')
In this case the two codes all output:
True
Upvotes: 0