Q: Truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all() with flask and yahoofinance I want the user to type a certain stock and have the application output the graph of said stock. I tried:
if request.method == 'POST':
        #text is the stock that the user input
        tickers_list = ['aapl', 'ebay', 'nue', 'f', 'tme', 'twtr', 'rblx', 'pfe', 't', 'wfc', 'msft', 'intc', 'tsla', 'pypl', 'hood', 'dis']
        text = str(request.form['Tickers'])
        print("The text is: ", text, file =sys.stderr)
        tickers = yf.Tickers(tickers_list)
        df = tickers.download(group_by='tickers')
        if df['EBAY'] == text:
            print("tickers: ", df.head(5), file =sys.stderr)
        df.plot.line()
        return render_template("addStock.html")

However the output keeps on giving me the error: ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

A: You obtain from yfinance a DataFrame with grouped columns e. g. Open, High for all your ticker symbols at different points in time.
The Sub-DF for df['EBAY'] looks similar to this one:
Open    High    Low Close   Volume  Dividends   Stock Splits
Date                            
2022-02-28  54.095833   54.763070   53.189589   54.364719   9280300 0.0 0
2022-03-01  54.334842   54.822818   53.717398   54.125706   9298800 0.0 0
2022-03-02  54.125708   55.221171   53.458475   54.862656   8496700 0.0 0
2022-03-03  55.410386   55.410386   53.239382   54.195419   6139200 0.0 0
2022-03-04  54.065956   56.207082   53.866781   55.430302   8300800 0.0 0


As the error indicates, you have to decide, whether all your values within a column / or series should match the string text or just one. You have to repeat this for all columns to come up with a final boolean, which can be used in the if condition.
Here is a stripped down version:
import yfinance as yf
import pandas as pd
import sys


# sample input
text = 0
df = pd.DataFrame(['foo', 'bar', 'foo'], columns=['EBAY'])

tickers_list = ['aapl', 'ebay', 'nue', 'f', 'tme', 'twtr', 'rblx', 'pfe', 't', 'wfc', 'msft', 'intc', 'tsla', 'pypl', 'hood', 'dis']
tickers = yf.Tickers(tickers_list)
df = tickers.download(group_by='tickers')

# adjust as needed
if (df['EBAY'] == text).any().any():
  print("tickers: ", df.head(5), file =sys.stderr)

