Here is some data:
import pandas as pd
df=pd.DataFrame( {'a': [1,2,3,4] })
df
a
0 1
1 2
2 3
3 4
I try to do the statements below:
if df.loc[df['a'] > 1].any() | df.loc[df['a'] < 3].any():
print("good")
else:
print("bad")
to print good when any value in column a is bigger than 1 or less than 3 but it gives this error:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
What is wrong with my code please?