Code by Scott B Miles.
from pandas import *
from __future__ import division
pandas.set_option('display.height', 500)
pandas.set_option('display.max_rows', 500)
pandas.set_option('display.max_columns', 500)
pandas.set_option('display.width', 500)
pandas.set_option('display.mpl_style', False)
rcParams['figure.figsize'] = 16, 8
xls1 = ExcelFile('CanterburyHotels.xlsx')
hotel_data = xls1.parse('data', parse_dates=[0], index_col=[0], na_values=['..'])
hotel_data.info()
<class 'pandas.core.frame.DataFrame'> DatetimeIndex: 204 entries, 1996-07-01 00:00:00 to 2013-06-01 00:00:00 Data columns (total 5 columns): Hotel units 204 non-null values Guest nights 204 non-null values Domestic guest nights 114 non-null values International guest nights 114 non-null values Occupancy rate 204 non-null values dtypes: float64(5)
hotel_data.plot(subplots=True)
array([<matplotlib.axes.AxesSubplot object at 0x6d76f70>, <matplotlib.axes.AxesSubplot object at 0x6d8ca50>, <matplotlib.axes.AxesSubplot object at 0x6f115d0>, <matplotlib.axes.AxesSubplot object at 0x6fac930>, <matplotlib.axes.AxesSubplot object at 0x6fd95b0>], dtype=object)
hotel_data.fillna(method='ffill', inplace=True)
hotel_data.plot(subplots=True)
array([<matplotlib.axes.AxesSubplot object at 0x7461310>, <matplotlib.axes.AxesSubplot object at 0x6d74ab0>, <matplotlib.axes.AxesSubplot object at 0x7690190>, <matplotlib.axes.AxesSubplot object at 0x76b0fd0>, <matplotlib.axes.AxesSubplot object at 0x76f0450>], dtype=object)
hotel_data_ma = rolling_mean(hotel_data,12, center=True)
hotel_data_ma['Hotel units'] = hotel_data['Hotel units']
hotel_data_ma.plot(subplots=True)
array([<matplotlib.axes.AxesSubplot object at 0x8367350>, <matplotlib.axes.AxesSubplot object at 0x83aaeb0>, <matplotlib.axes.AxesSubplot object at 0x86d41f0>, <matplotlib.axes.AxesSubplot object at 0x8717210>, <matplotlib.axes.AxesSubplot object at 0x874a4b0>], dtype=object)
hotel_data_residuals = hotel_data - hotel_data_ma
hotel_data_sf_1yr = hotel_data_residuals.groupby(lambda x: x.month).mean()
hotel_data_sf_1yr = hotel_data_sf_1yr.add_prefix('SF ')
hotel_data_sf_1yr
SF Hotel units | SF Guest nights | SF Domestic guest nights | SF International guest nights | SF Occupancy rate | |
---|---|---|---|---|---|
1 | 0 | 186.637255 | 88.348039 | 81.950980 | 8.297451 |
2 | 0 | 96.979167 | 56.062500 | 77.192708 | 17.268906 |
3 | 0 | 88.895833 | 61.156250 | 68.317708 | 11.183385 |
4 | 0 | 16.562500 | 0.531250 | -1.703125 | 1.897135 |
5 | 0 | -111.666667 | -20.166667 | -20.484375 | -10.624427 |
6 | 0 | -139.010417 | -24.963542 | -27.255208 | -13.910208 |
7 | 0 | -79.505208 | -34.916667 | -63.098958 | -8.322344 |
8 | 0 | -95.838542 | -42.364583 | -62.421875 | -9.047031 |
9 | 0 | -64.010417 | -36.973958 | -60.140625 | -5.753594 |
10 | 0 | -8.968750 | -15.260417 | -11.583333 | -0.361510 |
11 | 0 | 32.265625 | -15.114583 | 5.255208 | 8.110208 |
12 | 0 | 77.458333 | -7.036458 | 14.880208 | 0.994844 |
hotel_data['Month'] = hotel_data.index.month
hotel_data_join = merge(hotel_data, hotel_data_sf_1yr, left_on='Month', right_index=True)
hotel_data_sf = hotel_data_join.drop(['Hotel units', 'Guest nights', 'Domestic guest nights',
'International guest nights', 'Occupancy rate', 'Month'], axis=1)
hotel_data_sf.columns = ['Hotel units', 'Guest nights', 'Domestic guest nights', 'International guest nights', 'Occupancy rate']
hotel_data = hotel_data.drop('Month', axis=1)
hotel_data_sa = hotel_data.add_prefix('SA ')
hotel_data_sa = hotel_data - hotel_data_sf
hotel_data_sa.plot(subplots=True)
array([<matplotlib.axes.AxesSubplot object at 0x8b12770>, <matplotlib.axes.AxesSubplot object at 0x8b59c70>, <matplotlib.axes.AxesSubplot object at 0x8d7c430>, <matplotlib.axes.AxesSubplot object at 0x8d9eb50>, <matplotlib.axes.AxesSubplot object at 0x8ddc4d0>], dtype=object)
hotel_data_ma = rolling_mean(hotel_data, 12, center=True)
hotel_data_ss = hotel_data / hotel_data_ma
hotel_data_ss_mo = hotel_data_ss.groupby(lambda x: x.month)
hotel_data_ss_mo_mean = hotel_data_ss_mo.mean()
hotel_data_si_1yr = hotel_data_ss_mo_mean * ( 12.0 / hotel_data_ss_mo_mean.sum() )
hotel_data_si_1yr = hotel_data_si_1yr.add_prefix('SI ')
hotel_data['Month'] = hotel_data.index.month
hotel_data_join = merge(hotel_data, hotel_data_si_1yr, left_on='Month', right_index=True)
hotel_data_si = hotel_data_join.drop(['Hotel units', 'Guest nights', 'Domestic guest nights',
'International guest nights', 'Occupancy rate', 'Month'], axis=1)
hotel_data_si.columns = ['Hotel units', 'Guest nights', 'Domestic guest nights', 'International guest nights', 'Occupancy rate']
hotel_data = hotel_data.drop('Month', axis=1)
hotel_data_si
Hotel units | Guest nights | Domestic guest nights | International guest nights | Occupancy rate | |
---|---|---|---|---|---|
Date | |||||
1996-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
1997-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
1998-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
1999-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2000-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2001-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2002-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2003-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2004-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2005-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2006-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2007-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2008-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2009-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2010-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2011-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
2012-07-01 | 0.992982 | 0.781409 | 0.827564 | 0.635216 | 0.837853 |
1996-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
1997-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
1998-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
1999-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2000-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2001-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2002-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2003-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2004-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2005-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2006-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2007-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2008-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2009-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2010-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2011-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
2012-08-01 | 0.999188 | 0.739706 | 0.793995 | 0.642076 | 0.824084 |
1996-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
1997-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
1998-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
1999-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2000-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2001-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2002-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2003-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2004-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2005-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2006-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2007-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2008-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2009-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2010-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2011-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
2012-09-01 | 1.001027 | 0.824574 | 0.817719 | 0.655126 | 0.887846 |
1996-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
1997-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
1998-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
1999-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2000-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2001-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2002-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2003-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2004-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2005-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2006-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2007-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2008-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2009-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2010-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2011-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
2012-10-01 | 1.006997 | 0.978495 | 0.921473 | 0.938809 | 0.993669 |
1996-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
1997-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
1998-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
1999-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2000-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2001-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2002-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2003-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2004-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2005-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2006-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2007-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2008-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2009-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2010-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2011-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
2012-11-01 | 1.006069 | 1.087585 | 0.922125 | 1.032470 | 1.159014 |
1996-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
1997-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
1998-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
1999-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2000-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2001-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2002-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2003-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2004-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2005-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2006-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2007-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2008-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2009-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2010-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2011-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
2012-12-01 | 1.010175 | 1.211946 | 0.959062 | 1.089723 | 1.019733 |
1997-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
1998-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
1999-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2000-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2001-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2002-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2003-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2004-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2005-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2006-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2007-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2008-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2009-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2010-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2011-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2012-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
2013-01-01 | 1.013262 | 1.514742 | 1.417777 | 1.470113 | 1.162888 |
1997-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
1998-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
1999-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2000-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2001-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2002-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2003-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2004-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2005-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2006-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2007-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2008-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2009-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2010-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2011-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2012-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
2013-02-01 | 1.010127 | 1.265104 | 1.270976 | 1.431676 | 1.337938 |
1997-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
1998-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
1999-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2000-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2001-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2002-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2003-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2004-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2005-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2006-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2007-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2008-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2009-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2010-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2011-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2012-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
2013-03-01 | 0.994655 | 1.237773 | 1.292965 | 1.380277 | 1.217998 |
1997-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
1998-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
1999-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2000-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2001-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2002-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2003-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2004-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2005-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2006-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2007-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2008-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2009-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2010-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2011-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2012-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
2013-04-01 | 0.992428 | 1.046247 | 0.995105 | 0.991051 | 1.037448 |
1997-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
1998-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
1999-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2000-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2001-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2002-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2003-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2004-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2005-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2006-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2007-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2008-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2009-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2010-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2011-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2012-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
2013-05-01 | 0.986324 | 0.693959 | 0.901442 | 0.886027 | 0.793199 |
1997-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
1998-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
1999-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2000-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2001-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2002-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2003-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2004-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2005-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2006-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2007-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2008-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2009-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2010-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2011-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2012-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
2013-06-01 | 0.986766 | 0.618460 | 0.879797 | 0.847433 | 0.728330 |
hotel_data_sa2 = hotel_data / hotel_data_si
hotel_data_sa2.plot(subplots=True)
array([<matplotlib.axes.AxesSubplot object at 0x8e5c1f0>, <matplotlib.axes.AxesSubplot object at 0x90c11f0>, <matplotlib.axes.AxesSubplot object at 0x90f1910>, <matplotlib.axes.AxesSubplot object at 0x93bffd0>, <matplotlib.axes.AxesSubplot object at 0x9510950>], dtype=object)
plot(hotel_data.index, hotel_data['Hotel units'], label='Raw')
plot(hotel_data.index, hotel_data_ma['Hotel units'], label='Centered Moving Average')
plot(hotel_data.index, hotel_data_sa['Hotel units'], label='Adjusted (Additive)')
plot(hotel_data.index, hotel_data_sa2['Hotel units'], label='Adjusted (Multiplicative)')
nz_eq = datetime(2011, 2, 1)
plot([nz_eq, nz_eq], [15000,7000], color='k', linestyle='--')
ylabel('Hotel units')
legend(loc='upper left')
annotate('Canterbury \nearthquake', xy=(nz_eq, 8500), xycoords='data',
xytext=(-65, 0), textcoords='offset points',
arrowprops=dict(arrowstyle="->"))
<matplotlib.text.Annotation at 0x9894f70>
plot(hotel_data.index, hotel_data['Guest nights'], label='Raw')
plot(hotel_data.index, hotel_data_ma['Guest nights'], label='Centered Moving Average')
plot(hotel_data.index, hotel_data_sa['Guest nights'], label='Adjusted (Additive)')
plot(hotel_data.index, hotel_data_sa2['Guest nights'], label='Adjusted (Multiplicative)')
nz_eq = datetime(2011, 2, 1)
plot([nz_eq, nz_eq], [700,100], color='k', linestyle='--')
ylabel('Guest nights')
legend(loc='upper left')
annotate('Canterbury \nearthquake', xy=(nz_eq, 150), xycoords='data',
xytext=(-65, 0), textcoords='offset points',
arrowprops=dict(arrowstyle="->"))
<matplotlib.text.Annotation at 0x9be2330>
plot(hotel_data.index, hotel_data['Domestic guest nights'], label='Raw')
plot(hotel_data.index, hotel_data_ma['Domestic guest nights'], label='Centered Moving Average')
plot(hotel_data.index, hotel_data_sa['Domestic guest nights'], label='Adjusted (Additive)')
plot(hotel_data.index, hotel_data_sa2['Domestic guest nights'], label='Adjusted (Multiplicative)')
nz_eq = datetime(2011, 2, 1)
plot([nz_eq, nz_eq], [350,100], color='k', linestyle='--')
ylabel('Domestic guest nights')
legend(loc='upper left')
annotate('Canterbury \nearthquake', xy=(nz_eq, 125), xycoords='data',
xytext=(-65, 0), textcoords='offset points',
arrowprops=dict(arrowstyle="->"))
<matplotlib.text.Annotation at 0x9fc3db0>
plot(hotel_data.index, hotel_data['International guest nights'], label='Raw')
plot(hotel_data.index, hotel_data_ma['International guest nights'], label='Centered Moving Average')
plot(hotel_data.index, hotel_data_sa['International guest nights'], label='Adjusted (Additive)')
plot(hotel_data.index, hotel_data_sa2['International guest nights'], label='Adjusted (Multiplicative)')
nz_eq = datetime(2011, 2, 1)
plot([nz_eq, nz_eq], [350,50], color='k', linestyle='--')
ylabel('International guest nights')
legend(loc='upper left')
annotate('Canterbury \nearthquake', xy=(nz_eq, 75), xycoords='data',
xytext=(-65, 0), textcoords='offset points',
arrowprops=dict(arrowstyle="->"))
<matplotlib.text.Annotation at 0x9cbd330>
plot(hotel_data.index, hotel_data['Occupancy rate'], label='Raw')
plot(hotel_data.index, hotel_data_ma['Occupancy rate'], label='Centered Moving Average')
plot(hotel_data.index, hotel_data_sa['Occupancy rate'], label='Adjusted (Additive)')
plot(hotel_data.index, hotel_data_sa2['Occupancy rate'], label='Adjusted (Multiplicative)')
nz_eq = datetime(2011, 2, 1)
plot([nz_eq, nz_eq], [80,20], color='k', linestyle='--')
ylabel('Occupancy rate (%)')
legend(loc='upper left')
annotate('Canterbury \nearthquake', xy=(nz_eq, 25), xycoords='data',
xytext=(-65, 0), textcoords='offset points',
arrowprops=dict(arrowstyle="->"))
<matplotlib.text.Annotation at 0xa47fdb0>
hotel_available = (hotel_data['Hotel units'] - hotel_data['Hotel units'] * ( hotel_data_sa['Occupancy rate'] / 100.0 ))
hotel_nights_per_available = hotel_data_sa['Guest nights'] / hotel_available
hotel_nights_per_available_dom = hotel_data_sa['Domestic guest nights'] / hotel_available
hotel_nights_per_available_int = hotel_data_sa['International guest nights'] / hotel_available
plot(hotel_data.index, hotel_available)
nz_eq = datetime(2011, 2, 1)
plot([nz_eq, nz_eq], [9000,3000], color='k', linestyle='--')
ylabel('Available units')
annotate('Canterbury \nearthquake', xy=(nz_eq, 3500), xycoords='data',
xytext=(-65, 0), textcoords='offset points',
arrowprops=dict(arrowstyle="->"))
<matplotlib.text.Annotation at 0xa6b7110>
plot(hotel_data.index, hotel_nights_per_available, label='All travelers')
plot(hotel_data.index, hotel_nights_per_available_dom, label='Domestic travelers')
plot(hotel_data.index, hotel_nights_per_available_int, label='International travelers')
plot(hotel_data.index, rolling_mean(hotel_nights_per_available,12,center=True), label='All travelers CMA')
plot(hotel_data.index, rolling_mean(hotel_nights_per_available_dom,12,center=True), label='Domestic travelers CMA')
plot(hotel_data.index, rolling_mean(hotel_nights_per_available_int,12,center=True), label='International travelers CMA')
nz_eq = datetime(2011, 2, 1)
plot([nz_eq, nz_eq], [.11,.0], color='k', linestyle='--')
ylabel('Guest nights per available units')
legend()
annotate('Canterbury \nearthquake', xy=(nz_eq, .01), xycoords='data',
xytext=(-65, 0), textcoords='offset points',
arrowprops=dict(arrowstyle="->"))
annotate('Created by Scott Miles', color='gray', xy=(10, 10), xycoords='axes points',
xytext=(0, 0), textcoords='offset points',
arrowprops=None)
<matplotlib.text.Annotation at 0xa72e6b0>
bob = (100 - hotel_data['Occupancy rate'])/100.0
plot(hotel_data.index, rolling_mean(hotel_available / hotel_data['Hotel units'],12,center=True))
plot(hotel_data.index, rolling_mean(bob, 12, center=True))
[<matplotlib.lines.Line2D at 0xcca40d0>]