Download EOD data from Yahoo Finance to a Python Pandas Dataframe

If you use the Pandas DataReader and get this message:

Google finance has been immediately deprecated due to large breaks in the API without the
introduction of a stable replacement. Pull Requests to re-enable these data
connectors are welcome.

This method worked for me 2019.04.15 after installing this

pip install fix_yahoo_finance

import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import pandas_datareader as pdr
import as web
import matplotlib.pyplot as plt
import numpy as np
import fix_yahoo_finance as fyf

Then it is working again


Attributes High       Low        Open       Close      Volume  Adj Close
Symbols    GOOG       GOOG       GOOG       GOOG       GOOG    GOOG
2017-01-03 789.630005 775.799988 778.809998 786.140015 1657300 786.140015
2017-01-04 791.340027 783.159973 788.359985 786.900024 1073000 786.900024
2017-01-05 794.479980 785.020020 786.080017 794.020020 1335200 794.020020
2017-01-06 807.900024 792.203979 795.260010 806.150024 1640200 806.150024
2017-01-09 809.966003 802.830017 806.400024 806.650024 1272400 806.650024

And since I always forget how to add a “diff from previous day” column, here it is:

data['DiffClose'] = data['Close'] - data['Close'].shift(-1)

This will add a “diff” column to the DataFrame. NOTE: don’t use column name “diff” since you then can’t use the dot-syntax!  data.diff is a function!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.