I have a data frame as follows,
import pandas as pd data = [[1, 10], [2, 20], [3, 30]]
df = pd.DataFrame(data, columns=["a", "b"])
To query row a == 2 and b == 20, the code
df[(df["a"]==2) & (df["b"]==20)]
works fine but
df[df["a"]==2 & df["b"]==20]
returns an error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Is there any underlying difference that results in this?