0


TypeError: string indices must be integers

I imported this library but it's not giving error

from pandas_datareader import data as pdr
import datetime as dt

start_date = dt.datetime(2021, 1, 1)
end_date = dt.datetime(2021, 12, 31)

df = pdr.get_data_yahoo('AAPL', start=start_date, end=end_date)
print(df.head())
  • 1
    Does this answer your question? ["TypeError: string indices must be integers" when getting data of a stock from Yahoo Finance using Pandas Datareader](https://stackoverflow.com/questions/74832296/typeerror-string-indices-must-be-integers-when-getting-data-of-a-stock-from-y) – Marcelo Paco Apr 21 '23 at 17:49

1 Answers1

0

You can import yfinance:

import yfinance as yf
yf.pdr_override()

Than just use your code. It works for me.