What is pandas Datareader

It is a library to download data online.

Official Documentation

Here is a list of data sources. Some require an API key. fred and stooq can obtain data without an API key.

Remote Data Access

Fred Economic Data

Data source provided by the St. Louis Fed.

Federal Reserve Economic Data

Time Series Graph of Fred NASDAQ

Let’s create a time series graph of NASDAQ. Also, let’s display the 200-period moving average SMA200. This can be done in just about 10 lines.

import pandas_datareader.data as pdr
import datetime as dt
import matplotlib.pyplot as plt

date_to = dt.date.today()
ticker_f = 'NASDAQ100'
df = pdr.DataReader(ticker_f, 'fred', '2015-01-01', date_to).dropna()
df['SMA200'] = df.rolling(window=200).mean()
df.plot()
plt.show()

Graph of Fred Unemployment Rate

Let’s take a look at the graph of monthly unemployment rates in the United States. You can understand the magnitude of the impact of Covid19/the novel coronavirus.

import pandas_datareader.data as pdr
import datetime as dt
import matplotlib.pyplot as plt

date_to = dt.date.today()
ticker_f = 'UNRATE'
df = pdr.DataReader(ticker_f, 'fred', '2015-01-01', date_to).dropna()
df.plot()
plt.show()

NASDAQ

You can easily retrieve NASDAQ symbols. You can check the ticker symbols.

from pandas_datareader.nasdaq_trader import get_nasdaq_symbols
symbols = get_nasdaq_symbols()
symbols.info()
symbols.head()
symbols[symbols.index=='MSFT']