Analyzing Bitcoin Data with PQP and Quandl.com


In [1]:
import pandas as pd
import urllib
import json
import matplotlib as mpl
mpl.use('agg')
import seaborn as sns; sns.set()
%matplotlib inline

In [2]:
def read_quandl(url):
    d = json.loads(urllib.urlopen(url).read())
    df = pd.DataFrame(d['data'], columns=d['column_names']).set_index('Date').sort()
    return df

Number of Bitcoins


In [3]:
url = "https://www.quandl.com/api/v1/datasets/BCHAIN/TOTBC.json"

In [4]:
number = read_quandl(url)

Number of Bitcoins in existence.


In [5]:
number.plot(figsize=(10, 5))


Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f9e82e38450>

Bitcoin Rate


In [6]:
url = "https://www.quandl.com/api/v1/datasets/BAVERAGE/USD.json"

In [7]:
quotes = read_quandl(url)

Historical Bitcoin rate in USD.


In [8]:
quotes[['24h Average', 'Total Volume']][quotes.index > '2012-12-31'].plot(
        subplots=True, figsize=(10, 5), color='b')


Out[8]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x7f9e82581690>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x7f9e825eec50>], dtype=object)

Bitcoin rate to the USD in 2015.


In [9]:
quotes[['24h Average', 'Total Volume']][quotes.index > '2014-12-31'].plot(
        subplots=True, figsize=(10, 5), color='b')


Out[9]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x7f9e8244b910>,
       <matplotlib.axes._subplots.AxesSubplot object at 0x7f9e822d5e50>], dtype=object)