In [4]:
%matplotlib inline
import pandas as pd
import numpy as np
import os
import seaborn as sns
import matplotlib.pyplot as plt
sns.set()
In [5]:
os.listdir('../clean_data/')
Out[5]:
In [6]:
df1 = pd.read_excel('../clean_data/SPF_aggregate_histogram.xlsx',sheetname='2016Q1',header = 0,index_col=1)
df1.head()
Out[6]:
In [7]:
mask = df1.columns.str.contains(',')
mask
Out[7]:
In [8]:
h1 = df1.loc['2016',mask]
h1
Out[8]:
In [9]:
hdf1 = pd.DataFrame(h1)
hdf1['id'] = np.arange(0,len(h1))
hdf1['ints'] = hdf1.index
hdf1.set_index('id',inplace=True)
hdf1
Out[9]:
In [10]:
hdf1['source'] = '2016Q1'
hdf1.rename(columns={'2016':'p'},inplace=True)
In [11]:
df2 = pd.read_excel('../clean_data/SPF_aggregate_histogram.xlsx',sheetname='2015Q4',header = 0,index_col=1)
df2.head()
Out[11]:
In [12]:
mask = df2.columns.str.contains(',')
mask
Out[12]:
In [13]:
h2 = df2.loc['2016',mask]
h2
Out[13]:
In [14]:
hdf2 = pd.DataFrame(h2)
hdf2['id'] = np.arange(0,len(h2))
hdf2['ints'] = hdf2.index
hdf2 = hdf2.set_index('id')
hdf2
Out[14]:
In [15]:
hdf2['source'] = '2015Q4'
hdf2.rename(columns={'2016':'p'},inplace=True)
In [16]:
hdf1.head()
Out[16]:
In [ ]:
In [ ]:
In [17]:
df = pd.concat([hdf1,hdf2],join='inner',ignore_index=True)
df.shape
Out[17]:
In [18]:
df
Out[18]:
In [20]:
plt.figure()
g = sns.barplot(x='ints', y='p',hue='source',data=df);
locs, labels = plt.xticks()
plt.setp(labels, rotation=45)
g.set_ylabel('probability')
g.set_xlabel('interval')
g.set_title('Aggregate histograms: HICP inflation in 2016')
plt.tight_layout()
#plt.savefig('../figures/2016-04-06' + '-aggregate_histograms_2016.png')
#plt.savefig('../figures/2016-04-06' + '-aggregate_histograms_2016.pdf')
#plt.savefig('../figures/2016-04-06' + 'ggregate_histograms_2016.eps')
#plt.savefig('../figures/2016-04-06' + '-aggregate_histograms_2016.svg')
plt.draw()
In [73]:
plt.savefig("../figures/2016-04-06" + "-aggregate_histograms_2016.png")
In [75]:
plt.savefig("../figures/2016-04-06" + "-aggregate_histograms_2016.jpeg")
In [77]:
plt
Out[77]:
In [78]:
plt.savefig('myfig')
In [ ]: