Quandl: US GDP, Implicit Price Deflator

In this notebook, we'll take a look at data set , available on Quantopian. This dataset spans from 1947 through the current day. It contains the value for the United States GDP, using the implicit price deflator by the US Federal Reserve via the FRED data initiative. We access this data via the API provided by Quandl. More details on this dataset can be found on Quandl's website.

Blaze

Before we dig into the data, we want to tell you about how you generally access Quantopian partner data sets. These datasets are available using the Blaze library. Blaze provides the Quantopian user with a convenient interface to access very large datasets.

Some of these sets (though not this one) are many millions of records. Bringing that data directly into Quantopian Research directly just is not viable. So Blaze allows us to provide a simple querying interface and shift the burden over to the server side.

To learn more about using Blaze and generally accessing Quantopian partner data, clone this tutorial notebook.

With preamble in place, let's get started:


In [2]:
# import the dataset
from quantopian.interactive.data.quandl import fred_gdpdef
# Since this data is public domain and provided by Quandl for free, there is no _free version of this
# data set, as found in the premium sets. This import gets you the entirety of this data set.

# import data operations
from odo import odo
# import other libraries we will use
import pandas as pd
import matplotlib.pyplot as plt

In [3]:
fred_gdpdef.sort('asof_date')


Out[3]:
asof_date value timestamp
0 1947-01-01 12.566 1947-01-01
1 1947-04-01 12.745 1947-04-01
2 1947-07-01 12.957 1947-07-01
3 1947-10-01 13.276 1947-10-01
4 1948-01-01 13.379 1948-01-01
5 1948-04-01 13.497 1948-04-01
6 1948-07-01 13.747 1948-07-01
7 1948-10-01 13.789 1948-10-01
8 1949-01-01 13.717 1949-01-01
9 1949-04-01 13.579 1949-04-01
10 1949-07-01 13.509 1949-07-01

The data goes all the way back to 1947 and is updated quarterly.

Blaze provides us with the first 10 rows of the data for display. Just to confirm, let's just count the number of rows in the Blaze expression:


In [9]:
fred_gdpdef.count()


Out[9]:
814

Let's go plot it for fun. This data set is definitely small enough to just put right into a Pandas DataFrame


In [4]:
gdpdef_df = odo(fred_gdpdef, pd.DataFrame)

gdpdef_df.plot(x='asof_date', y='value')
plt.xlabel("As Of Date (asof_date)")
plt.ylabel("GDP Rate")
plt.title("US GDP, Implicit Price Deflator")
plt.legend().set_visible(False)



In [ ]: