In [1]:
import urllib2
from datetime import datetime
import pandas as pd
import pandas.io.data as web
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
pd.set_option('max_columns', 50)
%matplotlib inline
In [2]:
url = "http://www.federalreserve.gov/datadownload/Output.aspx?rel=H15&series=bcb44e57fb57efbe90002369321bfb3f&lastObs=&from=&to=&filetype=csv&label=include&layout=seriescolumn"
res = urllib2.Request(url)
csvio = urllib2.urlopen(res)
data = pd.read_csv(csvio, header=5, index_col=0, parse_dates=True, na_values=["ND"])
In [3]:
data.info()
data.plot(figsize=(10, 10))
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 13629 entries, 1962-01-02 00:00:00 to 2014-03-28 00:00:00
Data columns (total 1 columns):
RIFLGFCY10_N.B    13044 non-null float64
dtypes: float64(1)
Out[3]:
<matplotlib.axes.AxesSubplot at 0x92e0ff0>
In [4]:
url = "http://www.federalreserve.gov/datadownload/Output.aspx?rel=FOR&series=5c8df3fd05e5b5ad4297328218040855&lastObs=&from=&to=&filetype=csv&label=include&layout=seriescolumn"
res = urllib2.Request(url)
csvio = urllib2.urlopen(res)
data1 = pd.read_csv(csvio, header=5, index_col=0, parse_dates=True, na_values=["ND"])
In [5]:
data1.info()
data1.plot(figsize=(10, 10))
<class 'pandas.core.frame.DataFrame'>
Index: 136 entries, 1980Q1 to 2013Q4
Data columns (total 4 columns):
DTFD%YPD.Q    136 non-null float64
DTFM%YPD.Q    136 non-null float64
DTFC%YPD.Q    136 non-null float64
DTF%YPD.Q     136 non-null float64
dtypes: float64(4)
Out[5]:
<matplotlib.axes.AxesSubplot at 0x93fffd0>
In [6]:
url = "http://www.federalreserve.gov/datadownload/Output.aspx?rel=H15&series=40afb80a445c5903ca2c4888e40f3f1f&lastObs=&from=&to=&filetype=csv&label=include&layout=seriescolumn"
res = urllib2.Request(url)
csvio = urllib2.urlopen(res)
data2 = pd.read_csv(csvio, header=5, index_col=0, parse_dates=True, na_values=["ND"])
In [7]:
data2.info()
data2.plot(figsize=(10, 10))
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 716 entries, 1954-07-01 00:00:00 to 2014-02-01 00:00:00
Data columns (total 1 columns):
RIFSPFF_N.M    716 non-null float64
dtypes: float64(1)
Out[7]:
<matplotlib.axes.AxesSubplot at 0x9a20f50>
In [9]:
url = "http://www.federalreserve.gov/datadownload/Output.aspx?rel=G17&series=38c557d559e8dd62aa18b8af9b626a25&lastObs=&from=&to=&filetype=csv&label=include&layout=seriescolumn"
res = urllib2.Request(url)
csvio = urllib2.urlopen(res)
data3 = pd.read_csv(csvio, header=5, index_col=0, parse_dates=True, na_values=["ND"])
In [10]:
data3.info()
data3.plot(figsize=(10, 10))
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 506 entries, 1972-01-01 00:00:00 to 2014-02-01 00:00:00
Data columns (total 1 columns):
GVIP.T50030.S    506 non-null float64
dtypes: float64(1)
Out[10]:
<matplotlib.axes.AxesSubplot at 0x9adbeb0>
In [13]:
data4 = data3.append(other=data2)
In [14]:
data4.info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 1222 entries, 1972-01-01 00:00:00 to 2014-02-01 00:00:00
Data columns (total 2 columns):
GVIP.T50030.S    506 non-null float64
RIFSPFF_N.M      716 non-null float64
dtypes: float64(2)
In [15]:
data4.columns
Out[15]:
Index([u'GVIP.T50030.S', u'RIFSPFF_N.M'], dtype='object')
In [61]:
plt.figure()
data4.plot(secondary_y=['GVIP.T50030.S'], figsize=(10, 10), style=['p','p'])
Out[61]:
<matplotlib.axes.AxesSubplot at 0xea507f0>
<matplotlib.figure.Figure at 0xd806650>
In [61]: