According to the “datareader” official site, to access the remote Yahoo Finance Data, it is suggested to use the following code:
import pandas_datareader.data as pdr
df = pdr.DataReader(‘GOOG’, ‘yahoo’, start=’2019-09-01’, end=’2019-10-09’)
df.head()
These codes will pop up an error message: “TypeError: string indices must be integers”.
Here is a solution to help you to get the Yahoo Finance remote data.
At first, install yfinance by
pip3 install yfinance
Then, use the following codes:
import pandas_datareader.data as pdr
import yfinance as yfin
yfin.pdr_override()
df = pdr.get_data_yahoo(‘GOOG’, start=’2019-09-01’, end=’2019-10-09’)
df.head()
Run these codes, you will see the framed data sheet shown on the terminal.