Search code examples
pandaspandas-datareader

Error when trying to get data from Yahoo via pandas_datareader


I have problem exciting the simplest code in pandas datareader here is the code:

import datetime as dt
import pandas_datareader as web

symbol = "FB"
start = dt.datetime(2020,1,1)
end = dt.datetime(2022,1,1)

df = web.Datareader(symbol, "yahoo", start,end)

Error : TypeError : string indices must be integers


Solution

  • pandas_datareader no longer works for yahoo. Try yfinance :

    import yfinance as yf
    symbol = "META"
    start = dt.datetime(2020,1,1)
    end = dt.datetime(2022,1,1)
    df = yf.download(symbol, start = start, end=end)