Created
April 17, 2017 18:33
-
-
Save JBed/a7116dee27d43cbd00b77558fc05442a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"%matplotlib inline" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>check_in_day</th>\n", | |
" <th>check_out_day</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>2017-01-08</td>\n", | |
" <td>2017-01-12</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>2017-01-14</td>\n", | |
" <td>2017-01-18</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>2017-02-20</td>\n", | |
" <td>2017-02-26</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" check_in_day check_out_day\n", | |
"0 2017-01-08 2017-01-12\n", | |
"1 2017-01-14 2017-01-18\n", | |
"2 2017-02-20 2017-02-26" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"stays = pd.DataFrame({'check_in_day':['Jan 08 2017','Jan 14 2017','Feb 20 2017'], \\\n", | |
" 'check_out_day':['Jan 12 2017','Jan 18 2017','Feb 26 2017']})\n", | |
"\n", | |
"stays['check_in_day'] = pd.to_datetime(stays['check_in_day'])\n", | |
"stays['check_out_day'] = pd.to_datetime(stays['check_out_day'])\n", | |
"\n", | |
"stays" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"### my idea is to refactor so that the index is the day and the column is True/False is occupied that night." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 13, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>occupied_that_night</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>2017-01-01</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-02</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-03</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-04</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-05</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" occupied_that_night\n", | |
"2017-01-01 False\n", | |
"2017-01-02 False\n", | |
"2017-01-03 False\n", | |
"2017-01-04 False\n", | |
"2017-01-05 False" | |
] | |
}, | |
"execution_count": 13, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# this is all of the days that the room could be occupied in Jan 2017\n", | |
"Jan_bookings = pd.DataFrame()\n", | |
"Jan_dateRange = pd.date_range(start='2017-01-01', end='2017-01-31')\n", | |
"Jan_bookings['occupied_that_night'] = [False]*len(Jan_dateRange)\n", | |
"Jan_bookings.index = Jan_dateRange\n", | |
"Jan_bookings.head()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"# make a df for the first stay \n", | |
"stay_i = pd.DataFrame()\n", | |
"dr = pd.date_range(start=stays.iloc[0]['check_in_day'],\\\n", | |
" end=stays.iloc[0]['check_out_day']-pd.Timedelta('1 day')\\\n", | |
" ,freq='D')\n", | |
"stay_i['stay_1'] = ['True']*len(dr)\n", | |
"stay_i.index = dr" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>0</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>2017-01-01</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-02</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-03</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-04</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-05</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-06</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-07</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-08</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-09</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-10</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-11</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-12</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-13</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-14</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-15</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-16</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-17</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-18</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-19</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-20</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-21</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-22</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-23</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-24</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-25</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-26</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-27</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-28</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-29</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-30</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-31</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" 0\n", | |
"2017-01-01 False\n", | |
"2017-01-02 False\n", | |
"2017-01-03 False\n", | |
"2017-01-04 False\n", | |
"2017-01-05 False\n", | |
"2017-01-06 False\n", | |
"2017-01-07 False\n", | |
"2017-01-08 True\n", | |
"2017-01-09 True\n", | |
"2017-01-10 True\n", | |
"2017-01-11 True\n", | |
"2017-01-12 False\n", | |
"2017-01-13 False\n", | |
"2017-01-14 False\n", | |
"2017-01-15 False\n", | |
"2017-01-16 False\n", | |
"2017-01-17 False\n", | |
"2017-01-18 False\n", | |
"2017-01-19 False\n", | |
"2017-01-20 False\n", | |
"2017-01-21 False\n", | |
"2017-01-22 False\n", | |
"2017-01-23 False\n", | |
"2017-01-24 False\n", | |
"2017-01-25 False\n", | |
"2017-01-26 False\n", | |
"2017-01-27 False\n", | |
"2017-01-28 False\n", | |
"2017-01-29 False\n", | |
"2017-01-30 False\n", | |
"2017-01-31 False" | |
] | |
}, | |
"execution_count": 16, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# and merge... collapse wiht any...\n", | |
"pd.merge(Jan_bookings, stay_i, left_index=True, right_index=True,\\\n", | |
" how='outer').fillna(False).any(axis=1).to_frame()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"# ok now we just need to loop" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"Jan_bookings = pd.DataFrame()\n", | |
"Jan_dateRange = pd.date_range(start='2017-01-01', end='2017-01-31')\n", | |
"Jan_bookings['occupied_that_night'] = [False]*len(Jan_dateRange)\n", | |
"Jan_bookings.index = Jan_dateRange\n", | |
"Jan_bookings.head()\n", | |
"\n", | |
"# now loop over the stays in Jan\n", | |
"for ii in range(len(stays)):\n", | |
" stay_i = pd.DataFrame()\n", | |
" dr = pd.date_range(start=stays.iloc[ii]['check_in_day'],\\\n", | |
" end=stays.iloc[ii]['check_out_day']-pd.Timedelta('1 day')\\\n", | |
" ,freq='D')\n", | |
" stay_i['Stay_i'] = [True]*len(dr)\n", | |
" stay_i.index = dr\n", | |
" Jan_bookings = pd.merge(Jan_bookings, stay_i, \\\n", | |
" left_index=True, right_index=True,\\\n", | |
" how='outer').fillna(False).any(axis=1).to_frame()\n", | |
"\n", | |
" " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 18, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>0</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>2017-01-01</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-02</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-03</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-04</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-05</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-06</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-07</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-08</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-09</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-10</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-11</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-12</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-13</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-14</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-15</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-16</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-17</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-18</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-19</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-20</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-21</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-22</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-23</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-24</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-25</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-26</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-27</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-28</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-29</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-30</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-01-31</th>\n", | |
" <td>False</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-02-20</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-02-21</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-02-22</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-02-23</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-02-24</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2017-02-25</th>\n", | |
" <td>True</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" 0\n", | |
"2017-01-01 False\n", | |
"2017-01-02 False\n", | |
"2017-01-03 False\n", | |
"2017-01-04 False\n", | |
"2017-01-05 False\n", | |
"2017-01-06 False\n", | |
"2017-01-07 False\n", | |
"2017-01-08 True\n", | |
"2017-01-09 True\n", | |
"2017-01-10 True\n", | |
"2017-01-11 True\n", | |
"2017-01-12 False\n", | |
"2017-01-13 False\n", | |
"2017-01-14 True\n", | |
"2017-01-15 True\n", | |
"2017-01-16 True\n", | |
"2017-01-17 True\n", | |
"2017-01-18 False\n", | |
"2017-01-19 False\n", | |
"2017-01-20 False\n", | |
"2017-01-21 False\n", | |
"2017-01-22 False\n", | |
"2017-01-23 False\n", | |
"2017-01-24 False\n", | |
"2017-01-25 False\n", | |
"2017-01-26 False\n", | |
"2017-01-27 False\n", | |
"2017-01-28 False\n", | |
"2017-01-29 False\n", | |
"2017-01-30 False\n", | |
"2017-01-31 False\n", | |
"2017-02-20 True\n", | |
"2017-02-21 True\n", | |
"2017-02-22 True\n", | |
"2017-02-23 True\n", | |
"2017-02-24 True\n", | |
"2017-02-25 True" | |
] | |
}, | |
"execution_count": 18, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"Jan_bookings" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>False</th>\n", | |
" <th>True</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>3</td>\n", | |
" <td>3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>3</td>\n", | |
" <td>3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>4</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>6</th>\n", | |
" <td>3</td>\n", | |
" <td>2</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
"0 False True \n", | |
"0 3 3\n", | |
"1 3 3\n", | |
"2 3 2\n", | |
"3 4 1\n", | |
"4 4 1\n", | |
"5 3 2\n", | |
"6 3 2" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"Jan_bookings.groupby(Jan_bookings.index.dayofweek)[0].value_counts().unstack()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 20, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<matplotlib.axes._subplots.AxesSubplot at 0x10c887240>" | |
] | |
}, | |
"execution_count": 20, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEDVJREFUeJzt3X+MZXV9xvH3w7KiRguNO9Ht/mBMoG3UKsJk0dA0VEO7\nCoGkYgJNVYw4iZGIiWkLtsFI0kaTRqrFSDaAorWCRWtXRS0pWKUtK7PbBVlW29ViWIIy/BDcgujq\np3/M0U7Hmb1nZu7s3fn6fiU3e35855wHMvvcs+eec0+qCklSW44adQBJ0vBZ7pLUIMtdkhpkuUtS\ngyx3SWqQ5S5JDbLcJalBlrskNchyl6QGHT2qHa9bt67Gx8dHtXtJWpV27tz5UFWNDRo3snIfHx9n\nampqVLuXpFUpyXf6jPO0jCQ1yHKXpAZZ7pLUIMtdkhpkuUtSg3qXe5I1Sf4jyefmWXdMkhuS7Euy\nI8n4MENKkhZnMUfuFwN7F1j3JuDRqjoBuAJ473KDSZKWrle5J9kInAlcvcCQc4DruukbgVcmyfLj\nSZKWou9NTH8N/Anw7AXWbwDuA6iqg0keA54DPDR7UJJJYBJg8+bNS8krLcn4JZ9f0e3f+54zV2zb\nqzm7RmfgkXuSs4AHq2rncndWVduqaqKqJsbGBt49K0laoj6nZU4Dzk5y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wP3AH9ZVY+NLFsj5f6fwAur6sdzlj8N2FNVJ44m\n2fIleWNVfXjUOQ4lyduAtwJ7gZOAi6vqH7t1u6rq5FHmO5QkX2cm8zHAd4GNs/6i7qiqF4804ABJ\ndjFTJFcDxUy5f4LucuSq+pfRpRssydeqaks3/WZmfo/+Afg94LNH+oFZkj3AS7pLxrcBT9B9v1a3\n/A9Gla2V0zI/BX4N+M6c5eu7davZu4EjutyBNwOnVNWB7uueb0wyXlXvZ6ZsjmQHq+onwBNJvlVV\njwNU1ZNJVsPvzgRwMfBnwB9X1e4kTx7ppT7L2lnTk8AZVTWd5K+A24EjutyBo6rqYDc9MetA5rYk\nu0cVCtop97cD/5zkv4D7umWbgROAixb8qSNEkrsWWgU893BmWaKjfnYqpqruTXI6MwV/PEd+uf8o\nyTOr6gnglJ8tTHIsq+DAoKp+ClyR5O+7P7/H6vp7fVSSX2Xm4o5U1TRAVf1PkoOH/tEjwt2z/nV9\nZ5KJqppK8uvAjwf98EpaTb8EC6qqL3b/M7fw/z9QvaM7KjvSPRf4feDROcsD/Nvhj7No30tyUlXt\nBuiO4M8CrgV+a7TRBvqdqnoKfl6UP7OW//tKjSNe942sr01yJvD4qPMswrHATmZ+1yvJ+qp6IMmz\nOPIPDAAuBN6f5M+Z+SbIf09yHzMHmReOMlgT59xXuyTXAB+uqtvmWfd3VfWHI4jVW5KNzJze+O48\n606rqn8dQSytYkmeCTy3qv571Fn6SPIrwPOZOWDeX1XfG3Eky12SWuRNTJLUIMtdkhpkuUtSgyx3\nSWrQ/wLzIqr7r9ItEgAAAABJRU5ErkJggg==\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x10c89fda0>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"# these would be the unoccupied nights\n", | |
"# Monday=0, Sunday=6\n", | |
"Jan_bookings.groupby(Jan_bookings.index.dayofweek)[0].value_counts()\\\n", | |
".unstack()[False].plot(kind='bar')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment