Querying automotive Quandl data in Python

A quick post on how to query data from Quandl in Python. Quandl can be installed with the “pip install” command in your command prompt. For this simply type “pip install quandl” in your Anaconda command prompt.

Quandl is the Wikipedia of data – only that not all of its content is free. Quandl maintains free and premium datasets that are forwarded to the platform from data providers such as the US Federal Reserve, stock exchanges etc.

You have to set up an account on Quandl’s website. After having confirmed your account you will receive your API-key. Only with this key you can use the quandl module in Python.

In the code below I retrieve a dataset on German automotive industry production output, provided by Deutsche Bundesbank via quandl
import quandl
# setting up API key
quandl.ApiConfig.api_key = "your key here"
import numpy
import pandas
# retrieving data from quandl in numpy format, then converting into pandas DataFrame
data = pandas.DataFrame(quandl.get("BUNDESBANK/BBDE1_M_DE_Y_BAA1_A2R290050_G_C_I10_A", returns="numpy"))
I retrieved the data as a time series in pandas DataFrame format; I plot the time series using matplotlib
import matplotlib.pyplot as plt
plt.plot(data["Date"], data["Value"],color="red")
plt.title("Manufactur output for motor vehicles, trailers, semi-trailers and other transport equipment; Germany",size=12)
plt.ylabel("index value",size = 12)
plt.xlabel("date", size =12)
Text(0.5, 0, 'date')
In this case it must be noted that the dataset is no longer maintained. This becomes clear when viewing the tail of the dataset:

Not all datasets are maintained and not all datasets are documented well. Still, Quandl is a powerful search engine for querying relevant datasets.

You May Also Like

Leave a Reply

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.