import yfinance as yf
df = yf.Ticker('spy').history(period='100d', interval='1d')
if df[df['Open'] < 400] :
print(df)
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
if (df['Open'] < 400).any():
print(df)
any()All output,Those larger than 400 will also be printed。
if (df['Open'] < 400).all():
print(df)
all()No error reported,No output at all。
How to solve this problem? Thank you!