pythonpython-3.xpandasyahoo-finance

TypeError: string indices must be integers in pandas_datareader.DataReader


I am trying to get facebook stock prices with pandas_datareader but it gives me this error. can anyone help me out?

company = 'FB'

start = dt.datetime(2012, 1, 1)
end = dt.datetime.now()

data = pdr.DataReader(company, 'yahoo', start, end)

Solution

  • Looks like yahoo made changes to their API:

    related git: https://github.com/pydata/pandas-datareader/issues/952

    One way can be:

    import yfinance as yf
    
    df = yf.download(company, start , end)
    

    yf.download also returns a dataframe.