Created
July 3, 2015 13:14
-
-
Save kanhua/fe694f5d6391465af789 to your computer and use it in GitHub Desktop.
pandas groupby
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": 48, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"%matplotlib inline\n", | |
"import pandas as pd\n", | |
"import matplotlib.pyplot as plt\n", | |
"from sklearn.metrics import f1_score,confusion_matrix\n", | |
"from ggplot import *" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 49, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>UNIT</th>\n", | |
" <th>DATEn</th>\n", | |
" <th>TIMEn</th>\n", | |
" <th>ENTRIESn</th>\n", | |
" <th>EXITSn</th>\n", | |
" <th>ENTRIESn_hourly</th>\n", | |
" <th>EXITSn_hourly</th>\n", | |
" <th>datetime</th>\n", | |
" <th>hour</th>\n", | |
" <th>day_week</th>\n", | |
" <th>...</th>\n", | |
" <th>pressurei</th>\n", | |
" <th>rain</th>\n", | |
" <th>tempi</th>\n", | |
" <th>wspdi</th>\n", | |
" <th>meanprecipi</th>\n", | |
" <th>meanpressurei</th>\n", | |
" <th>meantempi</th>\n", | |
" <th>meanwspdi</th>\n", | |
" <th>weather_lat</th>\n", | |
" <th>weather_lon</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>0</th>\n", | |
" <td>R003</td>\n", | |
" <td>05-01-11</td>\n", | |
" <td>00:00:00</td>\n", | |
" <td>4388333</td>\n", | |
" <td>2911002</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>2011-05-01 00:00:00</td>\n", | |
" <td>0</td>\n", | |
" <td>6</td>\n", | |
" <td>...</td>\n", | |
" <td>30.22</td>\n", | |
" <td>0</td>\n", | |
" <td>55.9</td>\n", | |
" <td>3.5</td>\n", | |
" <td>0</td>\n", | |
" <td>30.258</td>\n", | |
" <td>55.98</td>\n", | |
" <td>7.86</td>\n", | |
" <td>40.700348</td>\n", | |
" <td>-73.887177</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>R003</td>\n", | |
" <td>05-01-11</td>\n", | |
" <td>04:00:00</td>\n", | |
" <td>4388333</td>\n", | |
" <td>2911002</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>2011-05-01 04:00:00</td>\n", | |
" <td>4</td>\n", | |
" <td>6</td>\n", | |
" <td>...</td>\n", | |
" <td>30.25</td>\n", | |
" <td>0</td>\n", | |
" <td>52.0</td>\n", | |
" <td>3.5</td>\n", | |
" <td>0</td>\n", | |
" <td>30.258</td>\n", | |
" <td>55.98</td>\n", | |
" <td>7.86</td>\n", | |
" <td>40.700348</td>\n", | |
" <td>-73.887177</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>R003</td>\n", | |
" <td>05-01-11</td>\n", | |
" <td>12:00:00</td>\n", | |
" <td>4388333</td>\n", | |
" <td>2911002</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>2011-05-01 12:00:00</td>\n", | |
" <td>12</td>\n", | |
" <td>6</td>\n", | |
" <td>...</td>\n", | |
" <td>30.28</td>\n", | |
" <td>0</td>\n", | |
" <td>62.1</td>\n", | |
" <td>6.9</td>\n", | |
" <td>0</td>\n", | |
" <td>30.258</td>\n", | |
" <td>55.98</td>\n", | |
" <td>7.86</td>\n", | |
" <td>40.700348</td>\n", | |
" <td>-73.887177</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>R003</td>\n", | |
" <td>05-01-11</td>\n", | |
" <td>16:00:00</td>\n", | |
" <td>4388333</td>\n", | |
" <td>2911002</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>2011-05-01 16:00:00</td>\n", | |
" <td>16</td>\n", | |
" <td>6</td>\n", | |
" <td>...</td>\n", | |
" <td>30.26</td>\n", | |
" <td>0</td>\n", | |
" <td>57.9</td>\n", | |
" <td>15.0</td>\n", | |
" <td>0</td>\n", | |
" <td>30.258</td>\n", | |
" <td>55.98</td>\n", | |
" <td>7.86</td>\n", | |
" <td>40.700348</td>\n", | |
" <td>-73.887177</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>R003</td>\n", | |
" <td>05-01-11</td>\n", | |
" <td>20:00:00</td>\n", | |
" <td>4388333</td>\n", | |
" <td>2911002</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>2011-05-01 20:00:00</td>\n", | |
" <td>20</td>\n", | |
" <td>6</td>\n", | |
" <td>...</td>\n", | |
" <td>30.28</td>\n", | |
" <td>0</td>\n", | |
" <td>52.0</td>\n", | |
" <td>10.4</td>\n", | |
" <td>0</td>\n", | |
" <td>30.258</td>\n", | |
" <td>55.98</td>\n", | |
" <td>7.86</td>\n", | |
" <td>40.700348</td>\n", | |
" <td>-73.887177</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>5 rows × 27 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" UNIT DATEn TIMEn ENTRIESn EXITSn ENTRIESn_hourly \\\n", | |
"0 R003 05-01-11 00:00:00 4388333 2911002 0 \n", | |
"1 R003 05-01-11 04:00:00 4388333 2911002 0 \n", | |
"2 R003 05-01-11 12:00:00 4388333 2911002 0 \n", | |
"3 R003 05-01-11 16:00:00 4388333 2911002 0 \n", | |
"4 R003 05-01-11 20:00:00 4388333 2911002 0 \n", | |
"\n", | |
" EXITSn_hourly datetime hour day_week ... pressurei \\\n", | |
"0 0 2011-05-01 00:00:00 0 6 ... 30.22 \n", | |
"1 0 2011-05-01 04:00:00 4 6 ... 30.25 \n", | |
"2 0 2011-05-01 12:00:00 12 6 ... 30.28 \n", | |
"3 0 2011-05-01 16:00:00 16 6 ... 30.26 \n", | |
"4 0 2011-05-01 20:00:00 20 6 ... 30.28 \n", | |
"\n", | |
" rain tempi wspdi meanprecipi meanpressurei meantempi meanwspdi \\\n", | |
"0 0 55.9 3.5 0 30.258 55.98 7.86 \n", | |
"1 0 52.0 3.5 0 30.258 55.98 7.86 \n", | |
"2 0 62.1 6.9 0 30.258 55.98 7.86 \n", | |
"3 0 57.9 15.0 0 30.258 55.98 7.86 \n", | |
"4 0 52.0 10.4 0 30.258 55.98 7.86 \n", | |
"\n", | |
" weather_lat weather_lon \n", | |
"0 40.700348 -73.887177 \n", | |
"1 40.700348 -73.887177 \n", | |
"2 40.700348 -73.887177 \n", | |
"3 40.700348 -73.887177 \n", | |
"4 40.700348 -73.887177 \n", | |
"\n", | |
"[5 rows x 27 columns]" | |
] | |
}, | |
"execution_count": 49, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"weather_data=pd.read_csv(\"./data/improved-dataset/turnstile_weather_v2.csv\")\n", | |
"weather_data.head()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 50, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<pandas.core.groupby.DataFrameGroupBy object at 0x10ed57f60>" | |
] | |
}, | |
"execution_count": 50, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"wp=weather_data.groupby([\"hour\",\"weekday\"])\n", | |
"wp" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Groupby object is similar to a python dict. They can be considered as key-value pairs. The keys are the column names that we tried to group. We can access the property ```groups``` to see this:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 51, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"dict_keys([(0, 1), (0, 0), (12, 1), (12, 0), (8, 1), (8, 0), (20, 1), (20, 0), (16, 1), (16, 0), (4, 1), (4, 0)])" | |
] | |
}, | |
"execution_count": 51, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"wp.groups.keys()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 52, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[5,\n", | |
" 11,\n", | |
" 16,\n", | |
" 22,\n", | |
" 27,\n", | |
" 43,\n", | |
" 49,\n", | |
" 54,\n", | |
" 60,\n", | |
" 66,\n", | |
" 82,\n", | |
" 88,\n", | |
" 94,\n", | |
" 99,\n", | |
" 104,\n", | |
" 120,\n", | |
" 126,\n", | |
" 132,\n", | |
" 135,\n", | |
" 141,\n", | |
" 156,\n", | |
" 162,\n", | |
" 174,\n", | |
" 180,\n", | |
" 186,\n", | |
" 190,\n", | |
" 196,\n", | |
" 212,\n", | |
" 218,\n", | |
" 224,\n", | |
" 229,\n", | |
" 234,\n", | |
" 250,\n", | |
" 256,\n", | |
" 262,\n", | |
" 268,\n", | |
" 274,\n", | |
" 290,\n", | |
" 296,\n", | |
" 302,\n", | |
" 308,\n", | |
" 314,\n", | |
" 331,\n", | |
" 337,\n", | |
" 348,\n", | |
" 354,\n", | |
" 360,\n", | |
" 365,\n", | |
" 371,\n", | |
" 387,\n", | |
" 392,\n", | |
" 397,\n", | |
" 402,\n", | |
" 408,\n", | |
" 426,\n", | |
" 432,\n", | |
" 438,\n", | |
" 444,\n", | |
" 449,\n", | |
" 465,\n", | |
" 471,\n", | |
" 477,\n", | |
" 483,\n", | |
" 488,\n", | |
" 504,\n", | |
" 509,\n", | |
" 521,\n", | |
" 528,\n", | |
" 534,\n", | |
" 540,\n", | |
" 558,\n", | |
" 564,\n", | |
" 570,\n", | |
" 576,\n", | |
" 582,\n", | |
" 600,\n", | |
" 606,\n", | |
" 612,\n", | |
" 618,\n", | |
" 624,\n", | |
" 642,\n", | |
" 648,\n", | |
" 654,\n", | |
" 659,\n", | |
" 665,\n", | |
" 683,\n", | |
" 689,\n", | |
" 699,\n", | |
" 704,\n", | |
" 709,\n", | |
" 715,\n", | |
" 720,\n", | |
" 735,\n", | |
" 740,\n", | |
" 746,\n", | |
" 752,\n", | |
" 757,\n", | |
" 774,\n", | |
" 780,\n", | |
" 785,\n", | |
" 791,\n", | |
" 797,\n", | |
" 814,\n", | |
" 820,\n", | |
" 826,\n", | |
" 832,\n", | |
" 838,\n", | |
" 853,\n", | |
" 859,\n", | |
" 870,\n", | |
" 876,\n", | |
" 882,\n", | |
" 887,\n", | |
" 892,\n", | |
" 908,\n", | |
" 914,\n", | |
" 920,\n", | |
" 925,\n", | |
" 930,\n", | |
" 946,\n", | |
" 952,\n", | |
" 958,\n", | |
" 963,\n", | |
" 968,\n", | |
" 983,\n", | |
" 989,\n", | |
" 995,\n", | |
" 1001,\n", | |
" 1006,\n", | |
" 1022,\n", | |
" 1028,\n", | |
" 1039,\n", | |
" 1045,\n", | |
" 1051,\n", | |
" 1057,\n", | |
" 1062,\n", | |
" 1078,\n", | |
" 1084,\n", | |
" 1090,\n", | |
" 1094,\n", | |
" 1100,\n", | |
" 1117,\n", | |
" 1123,\n", | |
" 1129,\n", | |
" 1135,\n", | |
" 1141,\n", | |
" 1157,\n", | |
" 1163,\n", | |
" 1169,\n", | |
" 1174,\n", | |
" 1179,\n", | |
" 1197,\n", | |
" 1203,\n", | |
" 1215,\n", | |
" 1221,\n", | |
" 1227,\n", | |
" 1233,\n", | |
" 1239,\n", | |
" 1256,\n", | |
" 1262,\n", | |
" 1268,\n", | |
" 1274,\n", | |
" 1280,\n", | |
" 1297,\n", | |
" 1303,\n", | |
" 1309,\n", | |
" 1315,\n", | |
" 1321,\n", | |
" 1339,\n", | |
" 1345,\n", | |
" 1351,\n", | |
" 1357,\n", | |
" 1363,\n", | |
" 1381,\n", | |
" 1387,\n", | |
" 1399,\n", | |
" 1405,\n", | |
" 1411,\n", | |
" 1417,\n", | |
" 1423,\n", | |
" 1441,\n", | |
" 1447,\n", | |
" 1453,\n", | |
" 1459,\n", | |
" 1465,\n", | |
" 1483,\n", | |
" 1489,\n", | |
" 1495,\n", | |
" 1501,\n", | |
" 1507,\n", | |
" 1525,\n", | |
" 1531,\n", | |
" 1537,\n", | |
" 1543,\n", | |
" 1549,\n", | |
" 1567,\n", | |
" 1573,\n", | |
" 1585,\n", | |
" 1591,\n", | |
" 1597,\n", | |
" 1603,\n", | |
" 1609,\n", | |
" 1627,\n", | |
" 1633,\n", | |
" 1639,\n", | |
" 1645,\n", | |
" 1651,\n", | |
" 1669,\n", | |
" 1675,\n", | |
" 1681,\n", | |
" 1687,\n", | |
" 1693,\n", | |
" 1711,\n", | |
" 1717,\n", | |
" 1723,\n", | |
" 1729,\n", | |
" 1735,\n", | |
" 1753,\n", | |
" 1759,\n", | |
" 1770,\n", | |
" 1776,\n", | |
" 1782,\n", | |
" 1788,\n", | |
" 1794,\n", | |
" 1811,\n", | |
" 1817,\n", | |
" 1823,\n", | |
" 1829,\n", | |
" 1835,\n", | |
" 1853,\n", | |
" 1859,\n", | |
" 1865,\n", | |
" 1871,\n", | |
" 1877,\n", | |
" 1895,\n", | |
" 1901,\n", | |
" 1907,\n", | |
" 1913,\n", | |
" 1919,\n", | |
" 1937,\n", | |
" 1943,\n", | |
" 1955,\n", | |
" 1961,\n", | |
" 1967,\n", | |
" 1973,\n", | |
" 1979,\n", | |
" 1997,\n", | |
" 2003,\n", | |
" 2009,\n", | |
" 2015,\n", | |
" 2021,\n", | |
" 2039,\n", | |
" 2045,\n", | |
" 2051,\n", | |
" 2057,\n", | |
" 2063,\n", | |
" 2081,\n", | |
" 2087,\n", | |
" 2093,\n", | |
" 2099,\n", | |
" 2105,\n", | |
" 2123,\n", | |
" 2129,\n", | |
" 2141,\n", | |
" 2147,\n", | |
" 2153,\n", | |
" 2159,\n", | |
" 2165,\n", | |
" 2182,\n", | |
" 2188,\n", | |
" 2194,\n", | |
" 2200,\n", | |
" 2206,\n", | |
" 2224,\n", | |
" 2230,\n", | |
" 2236,\n", | |
" 2242,\n", | |
" 2248,\n", | |
" 2266,\n", | |
" 2272,\n", | |
" 2278,\n", | |
" 2284,\n", | |
" 2290,\n", | |
" 2308,\n", | |
" 2314,\n", | |
" 2326,\n", | |
" 2332,\n", | |
" 2338,\n", | |
" 2344,\n", | |
" 2350,\n", | |
" 2368,\n", | |
" 2374,\n", | |
" 2380,\n", | |
" 2386,\n", | |
" 2392,\n", | |
" 2410,\n", | |
" 2416,\n", | |
" 2422,\n", | |
" 2428,\n", | |
" 2434,\n", | |
" 2452,\n", | |
" 2458,\n", | |
" 2464,\n", | |
" 2470,\n", | |
" 2476,\n", | |
" 2494,\n", | |
" 2500,\n", | |
" 2512,\n", | |
" 2518,\n", | |
" 2524,\n", | |
" 2530,\n", | |
" 2536,\n", | |
" 2554,\n", | |
" 2560,\n", | |
" 2566,\n", | |
" 2572,\n", | |
" 2578,\n", | |
" 2596,\n", | |
" 2602,\n", | |
" 2608,\n", | |
" 2614,\n", | |
" 2620,\n", | |
" 2638,\n", | |
" 2644,\n", | |
" 2650,\n", | |
" 2656,\n", | |
" 2662,\n", | |
" 2680,\n", | |
" 2686,\n", | |
" 2698,\n", | |
" 2704,\n", | |
" 2710,\n", | |
" 2716,\n", | |
" 2722,\n", | |
" 2740,\n", | |
" 2746,\n", | |
" 2752,\n", | |
" 2758,\n", | |
" 2764,\n", | |
" 2781,\n", | |
" 2787,\n", | |
" 2793,\n", | |
" 2799,\n", | |
" 2805,\n", | |
" 2823,\n", | |
" 2828,\n", | |
" 2834,\n", | |
" 2840,\n", | |
" 2846,\n", | |
" 2864,\n", | |
" 2870,\n", | |
" 2882,\n", | |
" 2888,\n", | |
" 2894,\n", | |
" 2900,\n", | |
" 2906,\n", | |
" 2924,\n", | |
" 2930,\n", | |
" 2936,\n", | |
" 2942,\n", | |
" 2948,\n", | |
" 2966,\n", | |
" 2972,\n", | |
" 2978,\n", | |
" 2984,\n", | |
" 2990,\n", | |
" 3008,\n", | |
" 3014,\n", | |
" 3020,\n", | |
" 3026,\n", | |
" 3032,\n", | |
" 3050,\n", | |
" 3056,\n", | |
" 3068,\n", | |
" 3074,\n", | |
" 3080,\n", | |
" 3086,\n", | |
" 3092,\n", | |
" 3110,\n", | |
" 3116,\n", | |
" 3122,\n", | |
" 3128,\n", | |
" 3134,\n", | |
" 3152,\n", | |
" 3158,\n", | |
" 3164,\n", | |
" 3170,\n", | |
" 3176,\n", | |
" 3194,\n", | |
" 3200,\n", | |
" 3206,\n", | |
" 3212,\n", | |
" 3218,\n", | |
" 3236,\n", | |
" 3242,\n", | |
" 3254,\n", | |
" 3260,\n", | |
" 3266,\n", | |
" 3272,\n", | |
" 3278,\n", | |
" 3296,\n", | |
" 3302,\n", | |
" 3308,\n", | |
" 3314,\n", | |
" 3319,\n", | |
" 3337,\n", | |
" 3343,\n", | |
" 3349,\n", | |
" 3355,\n", | |
" 3361,\n", | |
" 3379,\n", | |
" 3385,\n", | |
" 3391,\n", | |
" 3397,\n", | |
" 3403,\n", | |
" 3421,\n", | |
" 3427,\n", | |
" 3439,\n", | |
" 3445,\n", | |
" 3451,\n", | |
" 3457,\n", | |
" 3463,\n", | |
" 3481,\n", | |
" 3487,\n", | |
" 3493,\n", | |
" 3499,\n", | |
" 3505,\n", | |
" 3523,\n", | |
" 3529,\n", | |
" 3535,\n", | |
" 3541,\n", | |
" 3547,\n", | |
" 3565,\n", | |
" 3571,\n", | |
" 3577,\n", | |
" 3583,\n", | |
" 3589,\n", | |
" 3607,\n", | |
" 3613,\n", | |
" 3625,\n", | |
" 3631,\n", | |
" 3637,\n", | |
" 3643,\n", | |
" 3649,\n", | |
" 3667,\n", | |
" 3673,\n", | |
" 3679,\n", | |
" 3685,\n", | |
" 3691,\n", | |
" 3709,\n", | |
" 3715,\n", | |
" 3721,\n", | |
" 3727,\n", | |
" 3733,\n", | |
" 3751,\n", | |
" 3757,\n", | |
" 3763,\n", | |
" 3769,\n", | |
" 3775,\n", | |
" 3793,\n", | |
" 3799,\n", | |
" 3811,\n", | |
" 3817,\n", | |
" 3823,\n", | |
" 3829,\n", | |
" 3835,\n", | |
" 3853,\n", | |
" 3859,\n", | |
" 3865,\n", | |
" 3871,\n", | |
" 3877,\n", | |
" 3895,\n", | |
" 3901,\n", | |
" 3907,\n", | |
" 3913,\n", | |
" 3919,\n", | |
" 3937,\n", | |
" 3943,\n", | |
" 3949,\n", | |
" 3955,\n", | |
" 3961,\n", | |
" 3979,\n", | |
" 3985,\n", | |
" 3997,\n", | |
" 4003,\n", | |
" 4009,\n", | |
" 4015,\n", | |
" 4021,\n", | |
" 4039,\n", | |
" 4045,\n", | |
" 4051,\n", | |
" 4057,\n", | |
" 4063,\n", | |
" 4081,\n", | |
" 4087,\n", | |
" 4093,\n", | |
" 4099,\n", | |
" 4105,\n", | |
" 4123,\n", | |
" 4129,\n", | |
" 4135,\n", | |
" 4141,\n", | |
" 4147,\n", | |
" 4165,\n", | |
" 4171,\n", | |
" 4183,\n", | |
" 4189,\n", | |
" 4195,\n", | |
" 4201,\n", | |
" 4207,\n", | |
" 4225,\n", | |
" 4231,\n", | |
" 4237,\n", | |
" 4243,\n", | |
" 4249,\n", | |
" 4267,\n", | |
" 4273,\n", | |
" 4279,\n", | |
" 4285,\n", | |
" 4291,\n", | |
" 4309,\n", | |
" 4315,\n", | |
" 4321,\n", | |
" 4327,\n", | |
" 4333,\n", | |
" 4351,\n", | |
" 4357,\n", | |
" 4369,\n", | |
" 4375,\n", | |
" 4381,\n", | |
" 4387,\n", | |
" 4393,\n", | |
" 4410,\n", | |
" 4416,\n", | |
" 4422,\n", | |
" 4428,\n", | |
" 4434,\n", | |
" 4452,\n", | |
" 4458,\n", | |
" 4464,\n", | |
" 4470,\n", | |
" 4476,\n", | |
" 4494,\n", | |
" 4500,\n", | |
" 4506,\n", | |
" 4512,\n", | |
" 4518,\n", | |
" 4536,\n", | |
" 4542,\n", | |
" 4554,\n", | |
" 4560,\n", | |
" 4566,\n", | |
" 4572,\n", | |
" 4578,\n", | |
" 4596,\n", | |
" 4602,\n", | |
" 4608,\n", | |
" 4614,\n", | |
" 4620,\n", | |
" 4638,\n", | |
" 4644,\n", | |
" 4650,\n", | |
" 4656,\n", | |
" 4662,\n", | |
" 4680,\n", | |
" 4686,\n", | |
" 4692,\n", | |
" 4698,\n", | |
" 4704,\n", | |
" 4722,\n", | |
" 4728,\n", | |
" 4740,\n", | |
" 4746,\n", | |
" 4752,\n", | |
" 4757,\n", | |
" 4763,\n", | |
" 4779,\n", | |
" 4785,\n", | |
" 4791,\n", | |
" 4796,\n", | |
" 4802,\n", | |
" 4816,\n", | |
" 4822,\n", | |
" 4828,\n", | |
" 4834,\n", | |
" 4840,\n", | |
" 4856,\n", | |
" 4862,\n", | |
" 4868,\n", | |
" 4874,\n", | |
" 4880,\n", | |
" 4892,\n", | |
" 4898,\n", | |
" 4910,\n", | |
" 4916,\n", | |
" 4922,\n", | |
" 4928,\n", | |
" 4934,\n", | |
" 4951,\n", | |
" 4957,\n", | |
" 4963,\n", | |
" 4969,\n", | |
" 4975,\n", | |
" 4993,\n", | |
" 4999,\n", | |
" 5005,\n", | |
" 5011,\n", | |
" 5017,\n", | |
" 5034,\n", | |
" 5040,\n", | |
" 5046,\n", | |
" 5052,\n", | |
" 5058,\n", | |
" 5076,\n", | |
" 5082,\n", | |
" 5093,\n", | |
" 5099,\n", | |
" 5105,\n", | |
" 5111,\n", | |
" 5117,\n", | |
" 5133,\n", | |
" 5139,\n", | |
" 5145,\n", | |
" 5150,\n", | |
" 5156,\n", | |
" 5173,\n", | |
" 5179,\n", | |
" 5185,\n", | |
" 5191,\n", | |
" 5197,\n", | |
" 5214,\n", | |
" 5220,\n", | |
" 5226,\n", | |
" 5232,\n", | |
" 5238,\n", | |
" 5253,\n", | |
" 5259,\n", | |
" 5271,\n", | |
" 5277,\n", | |
" 5283,\n", | |
" 5289,\n", | |
" 5295,\n", | |
" 5313,\n", | |
" 5319,\n", | |
" 5325,\n", | |
" 5330,\n", | |
" 5336,\n", | |
" 5352,\n", | |
" 5358,\n", | |
" 5364,\n", | |
" 5370,\n", | |
" 5376,\n", | |
" 5394,\n", | |
" 5400,\n", | |
" 5406,\n", | |
" 5412,\n", | |
" 5418,\n", | |
" 5436,\n", | |
" 5442,\n", | |
" 5454,\n", | |
" 5460,\n", | |
" 5466,\n", | |
" 5472,\n", | |
" 5477,\n", | |
" 5494,\n", | |
" 5500,\n", | |
" 5509,\n", | |
" 5515,\n", | |
" 5531,\n", | |
" 5542,\n", | |
" 5548,\n", | |
" 5554,\n", | |
" 5571,\n", | |
" 5577,\n", | |
" 5582,\n", | |
" 5587,\n", | |
" 5593,\n", | |
" 5611,\n", | |
" 5617,\n", | |
" 5629,\n", | |
" 5635,\n", | |
" 5641,\n", | |
" 5646,\n", | |
" 5651,\n", | |
" 5667,\n", | |
" 5672,\n", | |
" 5678,\n", | |
" 5683,\n", | |
" 5689,\n", | |
" 5705,\n", | |
" 5711,\n", | |
" 5717,\n", | |
" 5722,\n", | |
" 5728,\n", | |
" 5745,\n", | |
" 5751,\n", | |
" 5757,\n", | |
" 5763,\n", | |
" 5768,\n", | |
" 5783,\n", | |
" 5794,\n", | |
" 5800,\n", | |
" 5806,\n", | |
" 5812,\n", | |
" 5818,\n", | |
" 5836,\n", | |
" 5842,\n", | |
" 5848,\n", | |
" 5854,\n", | |
" 5859,\n", | |
" 5877,\n", | |
" 5883,\n", | |
" 5889,\n", | |
" 5895,\n", | |
" 5901,\n", | |
" 5919,\n", | |
" 5925,\n", | |
" 5931,\n", | |
" 5937,\n", | |
" 5943,\n", | |
" 5961,\n", | |
" 5967,\n", | |
" 5979,\n", | |
" 5985,\n", | |
" 5991,\n", | |
" 5997,\n", | |
" 6003,\n", | |
" 6021,\n", | |
" 6027,\n", | |
" 6033,\n", | |
" 6039,\n", | |
" 6045,\n", | |
" 6063,\n", | |
" 6069,\n", | |
" 6075,\n", | |
" 6081,\n", | |
" 6087,\n", | |
" 6105,\n", | |
" 6111,\n", | |
" 6117,\n", | |
" 6123,\n", | |
" 6129,\n", | |
" 6147,\n", | |
" 6153,\n", | |
" 6164,\n", | |
" 6170,\n", | |
" 6176,\n", | |
" 6182,\n", | |
" 6188,\n", | |
" 6205,\n", | |
" 6211,\n", | |
" 6216,\n", | |
" 6222,\n", | |
" 6228,\n", | |
" 6245,\n", | |
" 6251,\n", | |
" 6257,\n", | |
" 6263,\n", | |
" 6269,\n", | |
" 6287,\n", | |
" 6293,\n", | |
" 6299,\n", | |
" 6305,\n", | |
" 6311,\n", | |
" 6327,\n", | |
" 6333,\n", | |
" 6345,\n", | |
" 6351,\n", | |
" 6357,\n", | |
" 6363,\n", | |
" 6369,\n", | |
" 6387,\n", | |
" 6393,\n", | |
" 6399,\n", | |
" 6405,\n", | |
" 6411,\n", | |
" 6429,\n", | |
" 6435,\n", | |
" 6441,\n", | |
" 6447,\n", | |
" 6453,\n", | |
" 6471,\n", | |
" 6477,\n", | |
" 6483,\n", | |
" 6489,\n", | |
" 6495,\n", | |
" 6513,\n", | |
" 6519,\n", | |
" 6531,\n", | |
" 6537,\n", | |
" 6543,\n", | |
" 6549,\n", | |
" 6555,\n", | |
" 6573,\n", | |
" 6579,\n", | |
" 6585,\n", | |
" 6591,\n", | |
" 6597,\n", | |
" 6615,\n", | |
" 6621,\n", | |
" 6627,\n", | |
" 6633,\n", | |
" 6639,\n", | |
" 6657,\n", | |
" 6663,\n", | |
" 6669,\n", | |
" 6675,\n", | |
" 6681,\n", | |
" 6699,\n", | |
" 6705,\n", | |
" 6717,\n", | |
" 6723,\n", | |
" 6729,\n", | |
" 6735,\n", | |
" 6741,\n", | |
" 6759,\n", | |
" 6765,\n", | |
" 6771,\n", | |
" 6777,\n", | |
" 6783,\n", | |
" 6801,\n", | |
" 6807,\n", | |
" 6813,\n", | |
" 6819,\n", | |
" 6825,\n", | |
" 6843,\n", | |
" 6849,\n", | |
" 6855,\n", | |
" 6861,\n", | |
" 6867,\n", | |
" 6885,\n", | |
" 6891,\n", | |
" 6903,\n", | |
" 6909,\n", | |
" 6915,\n", | |
" 6921,\n", | |
" 6927,\n", | |
" 6945,\n", | |
" 6951,\n", | |
" 6957,\n", | |
" 6963,\n", | |
" 6969,\n", | |
" 6987,\n", | |
" 6993,\n", | |
" 6999,\n", | |
" 7005,\n", | |
" 7011,\n", | |
" 7029,\n", | |
" 7035,\n", | |
" 7041,\n", | |
" 7047,\n", | |
" 7053,\n", | |
" 7071,\n", | |
" 7077,\n", | |
" 7089,\n", | |
" 7095,\n", | |
" 7101,\n", | |
" 7106,\n", | |
" 7112,\n", | |
" 7130,\n", | |
" 7136,\n", | |
" 7142,\n", | |
" 7148,\n", | |
" 7154,\n", | |
" 7172,\n", | |
" 7177,\n", | |
" 7183,\n", | |
" 7189,\n", | |
" 7195,\n", | |
" 7213,\n", | |
" 7219,\n", | |
" 7225,\n", | |
" 7231,\n", | |
" 7237,\n", | |
" 7255,\n", | |
" 7261,\n", | |
" 7273,\n", | |
" 7279,\n", | |
" 7285,\n", | |
" 7291,\n", | |
" 7297,\n", | |
" 7315,\n", | |
" 7321,\n", | |
" 7327,\n", | |
" 7333,\n", | |
" 7339,\n", | |
" 7357,\n", | |
" 7363,\n", | |
" 7369,\n", | |
" 7375,\n", | |
" 7381,\n", | |
" 7399,\n", | |
" 7405,\n", | |
" 7411,\n", | |
" 7417,\n", | |
" 7423,\n", | |
" 7441,\n", | |
" 7447,\n", | |
" 7459,\n", | |
" 7465,\n", | |
" 7471,\n", | |
" 7476,\n", | |
" 7482,\n", | |
" 7498,\n", | |
" 7504,\n", | |
" 7510,\n", | |
" 7515,\n", | |
" 7520,\n", | |
" 7537,\n", | |
" 7543,\n", | |
" 7549,\n", | |
" 7555,\n", | |
" 7560,\n", | |
" 7576,\n", | |
" 7580,\n", | |
" 7585,\n", | |
" 7591,\n", | |
" 7597,\n", | |
" 7613,\n", | |
" 7619,\n", | |
" 7631,\n", | |
" 7637,\n", | |
" 7643,\n", | |
" 7649,\n", | |
" 7655,\n", | |
" 7672,\n", | |
" 7678,\n", | |
" 7684,\n", | |
" 7690,\n", | |
" 7696,\n", | |
" 7714,\n", | |
" 7720,\n", | |
" 7726,\n", | |
" 7732,\n", | |
" 7738,\n", | |
" 7755,\n", | |
" 7761,\n", | |
" 7767,\n", | |
" 7773,\n", | |
" 7779,\n", | |
" 7797,\n", | |
" 7803,\n", | |
" 7815,\n", | |
" 7821,\n", | |
" 7827,\n", | |
" 7833,\n", | |
" 7839,\n", | |
" 7857,\n", | |
" 7863,\n", | |
" 7869,\n", | |
" 7875,\n", | |
" 7881,\n", | |
" 7898,\n", | |
" 7904,\n", | |
" 7910,\n", | |
" 7915,\n", | |
" 7921,\n", | |
" 7939,\n", | |
" 7945,\n", | |
" 7951,\n", | |
" 7957,\n", | |
" 7963,\n", | |
" 7981,\n", | |
" 7987,\n", | |
" 7999,\n", | |
" 8005,\n", | |
" 8011,\n", | |
" 8017,\n", | |
" 8023,\n", | |
" 8041,\n", | |
" 8047,\n", | |
" 8053,\n", | |
" 8059,\n", | |
" 8065,\n", | |
" 8083,\n", | |
" 8089,\n", | |
" 8095,\n", | |
" 8101,\n", | |
" 8107,\n", | |
" 8125,\n", | |
" 8131,\n", | |
" 8137,\n", | |
" 8143,\n", | |
" 8149,\n", | |
" 8167,\n", | |
" 8173,\n", | |
" 8185,\n", | |
" 8191,\n", | |
" 8197,\n", | |
" 8203,\n", | |
" 8209,\n", | |
" 8226,\n", | |
" 8232,\n", | |
" 8238,\n", | |
" 8244,\n", | |
" 8250,\n", | |
" 8267,\n", | |
" 8273,\n", | |
" 8279,\n", | |
" 8285,\n", | |
" ...]" | |
] | |
}, | |
"execution_count": 52, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"wp.groups[(0,1)] # Return the row indexes that hour=0 and weekday=1 " | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Return a new dataframe with the number of entries of each ```(hour,weekday)``` pair" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 53, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th>UNIT</th>\n", | |
" <th>DATEn</th>\n", | |
" <th>TIMEn</th>\n", | |
" <th>ENTRIESn</th>\n", | |
" <th>EXITSn</th>\n", | |
" <th>ENTRIESn_hourly</th>\n", | |
" <th>EXITSn_hourly</th>\n", | |
" <th>datetime</th>\n", | |
" <th>day_week</th>\n", | |
" <th>station</th>\n", | |
" <th>...</th>\n", | |
" <th>pressurei</th>\n", | |
" <th>rain</th>\n", | |
" <th>tempi</th>\n", | |
" <th>wspdi</th>\n", | |
" <th>meanprecipi</th>\n", | |
" <th>meanpressurei</th>\n", | |
" <th>meantempi</th>\n", | |
" <th>meanwspdi</th>\n", | |
" <th>weather_lat</th>\n", | |
" <th>weather_lon</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>hour</th>\n", | |
" <th>weekday</th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">0</th>\n", | |
" <th>0</th>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>...</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" <td>2142</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>...</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" <td>5236</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">4</th>\n", | |
" <th>0</th>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>...</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" <td>2140</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>...</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" <td>5241</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">8</th>\n", | |
" <th>0</th>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>...</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" <td>1487</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>...</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" <td>4427</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">12</th>\n", | |
" <th>0</th>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>...</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" <td>2132</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>...</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" <td>5203</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">16</th>\n", | |
" <th>0</th>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>...</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" <td>2134</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>...</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" <td>5164</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">20</th>\n", | |
" <th>0</th>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>...</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" <td>2144</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>...</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" <td>5199</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"<p>12 rows × 25 columns</p>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" UNIT DATEn TIMEn ENTRIESn EXITSn ENTRIESn_hourly \\\n", | |
"hour weekday \n", | |
"0 0 2142 2142 2142 2142 2142 2142 \n", | |
" 1 5236 5236 5236 5236 5236 5236 \n", | |
"4 0 2140 2140 2140 2140 2140 2140 \n", | |
" 1 5241 5241 5241 5241 5241 5241 \n", | |
"8 0 1487 1487 1487 1487 1487 1487 \n", | |
" 1 4427 4427 4427 4427 4427 4427 \n", | |
"12 0 2132 2132 2132 2132 2132 2132 \n", | |
" 1 5203 5203 5203 5203 5203 5203 \n", | |
"16 0 2134 2134 2134 2134 2134 2134 \n", | |
" 1 5164 5164 5164 5164 5164 5164 \n", | |
"20 0 2144 2144 2144 2144 2144 2144 \n", | |
" 1 5199 5199 5199 5199 5199 5199 \n", | |
"\n", | |
" EXITSn_hourly datetime day_week station ... \\\n", | |
"hour weekday ... \n", | |
"0 0 2142 2142 2142 2142 ... \n", | |
" 1 5236 5236 5236 5236 ... \n", | |
"4 0 2140 2140 2140 2140 ... \n", | |
" 1 5241 5241 5241 5241 ... \n", | |
"8 0 1487 1487 1487 1487 ... \n", | |
" 1 4427 4427 4427 4427 ... \n", | |
"12 0 2132 2132 2132 2132 ... \n", | |
" 1 5203 5203 5203 5203 ... \n", | |
"16 0 2134 2134 2134 2134 ... \n", | |
" 1 5164 5164 5164 5164 ... \n", | |
"20 0 2144 2144 2144 2144 ... \n", | |
" 1 5199 5199 5199 5199 ... \n", | |
"\n", | |
" pressurei rain tempi wspdi meanprecipi meanpressurei \\\n", | |
"hour weekday \n", | |
"0 0 2142 2142 2142 2142 2142 2142 \n", | |
" 1 5236 5236 5236 5236 5236 5236 \n", | |
"4 0 2140 2140 2140 2140 2140 2140 \n", | |
" 1 5241 5241 5241 5241 5241 5241 \n", | |
"8 0 1487 1487 1487 1487 1487 1487 \n", | |
" 1 4427 4427 4427 4427 4427 4427 \n", | |
"12 0 2132 2132 2132 2132 2132 2132 \n", | |
" 1 5203 5203 5203 5203 5203 5203 \n", | |
"16 0 2134 2134 2134 2134 2134 2134 \n", | |
" 1 5164 5164 5164 5164 5164 5164 \n", | |
"20 0 2144 2144 2144 2144 2144 2144 \n", | |
" 1 5199 5199 5199 5199 5199 5199 \n", | |
"\n", | |
" meantempi meanwspdi weather_lat weather_lon \n", | |
"hour weekday \n", | |
"0 0 2142 2142 2142 2142 \n", | |
" 1 5236 5236 5236 5236 \n", | |
"4 0 2140 2140 2140 2140 \n", | |
" 1 5241 5241 5241 5241 \n", | |
"8 0 1487 1487 1487 1487 \n", | |
" 1 4427 4427 4427 4427 \n", | |
"12 0 2132 2132 2132 2132 \n", | |
" 1 5203 5203 5203 5203 \n", | |
"16 0 2134 2134 2134 2134 \n", | |
" 1 5164 5164 5164 5164 \n", | |
"20 0 2144 2144 2144 2144 \n", | |
" 1 5199 5199 5199 5199 \n", | |
"\n", | |
"[12 rows x 25 columns]" | |
] | |
}, | |
"execution_count": 53, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"wc=wp.count()\n", | |
"wc" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Return a new dataframe with the number of entries of each ```(hour,weekday)``` pair" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 54, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th>ENTRIESn</th>\n", | |
" <th>EXITSn</th>\n", | |
" <th>ENTRIESn_hourly</th>\n", | |
" <th>EXITSn_hourly</th>\n", | |
" <th>day_week</th>\n", | |
" <th>latitude</th>\n", | |
" <th>longitude</th>\n", | |
" <th>fog</th>\n", | |
" <th>precipi</th>\n", | |
" <th>pressurei</th>\n", | |
" <th>rain</th>\n", | |
" <th>tempi</th>\n", | |
" <th>wspdi</th>\n", | |
" <th>meanprecipi</th>\n", | |
" <th>meanpressurei</th>\n", | |
" <th>meantempi</th>\n", | |
" <th>meanwspdi</th>\n", | |
" <th>weather_lat</th>\n", | |
" <th>weather_lon</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>hour</th>\n", | |
" <th>weekday</th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">0</th>\n", | |
" <th>0</th>\n", | |
" <td>63712687826</td>\n", | |
" <td>44939043396</td>\n", | |
" <td>3161210</td>\n", | |
" <td>2537164</td>\n", | |
" <td>11902</td>\n", | |
" <td>87231.063258</td>\n", | |
" <td>-158379.460616</td>\n", | |
" <td>0</td>\n", | |
" <td>0.00</td>\n", | |
" <td>64171.22</td>\n", | |
" <td>295</td>\n", | |
" <td>129012.7</td>\n", | |
" <td>9085.7</td>\n", | |
" <td>3.529000</td>\n", | |
" <td>64177.229333</td>\n", | |
" <td>135503.341667</td>\n", | |
" <td>12522.123333</td>\n", | |
" <td>87239.766206</td>\n", | |
" <td>-158375.801147</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>153149943567</td>\n", | |
" <td>108048090886</td>\n", | |
" <td>7191957</td>\n", | |
" <td>5722665</td>\n", | |
" <td>9752</td>\n", | |
" <td>213231.965466</td>\n", | |
" <td>-387148.771307</td>\n", | |
" <td>0</td>\n", | |
" <td>46.35</td>\n", | |
" <td>157011.83</td>\n", | |
" <td>1349</td>\n", | |
" <td>313620.2</td>\n", | |
" <td>30492.7</td>\n", | |
" <td>30.022000</td>\n", | |
" <td>156949.264167</td>\n", | |
" <td>329963.468333</td>\n", | |
" <td>38481.118333</td>\n", | |
" <td>213253.350657</td>\n", | |
" <td>-387139.695161</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">4</th>\n", | |
" <th>0</th>\n", | |
" <td>62392039290</td>\n", | |
" <td>44166326953</td>\n", | |
" <td>727273</td>\n", | |
" <td>734428</td>\n", | |
" <td>11887</td>\n", | |
" <td>87149.877929</td>\n", | |
" <td>-158231.085448</td>\n", | |
" <td>0</td>\n", | |
" <td>10.78</td>\n", | |
" <td>64104.73</td>\n", | |
" <td>297</td>\n", | |
" <td>124710.4</td>\n", | |
" <td>8726.6</td>\n", | |
" <td>3.545000</td>\n", | |
" <td>64116.531333</td>\n", | |
" <td>135335.941667</td>\n", | |
" <td>12516.253333</td>\n", | |
" <td>87158.616124</td>\n", | |
" <td>-158227.501251</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>167128298182</td>\n", | |
" <td>117943547302</td>\n", | |
" <td>1573515</td>\n", | |
" <td>1479628</td>\n", | |
" <td>9753</td>\n", | |
" <td>213435.880640</td>\n", | |
" <td>-387518.473888</td>\n", | |
" <td>24</td>\n", | |
" <td>36.28</td>\n", | |
" <td>157107.19</td>\n", | |
" <td>1353</td>\n", | |
" <td>307984.3</td>\n", | |
" <td>27618.8</td>\n", | |
" <td>30.071500</td>\n", | |
" <td>157099.596833</td>\n", | |
" <td>330257.781667</td>\n", | |
" <td>38569.438333</td>\n", | |
" <td>213457.281137</td>\n", | |
" <td>-387509.368133</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">8</th>\n", | |
" <th>0</th>\n", | |
" <td>30122489421</td>\n", | |
" <td>21296628669</td>\n", | |
" <td>363408</td>\n", | |
" <td>274662</td>\n", | |
" <td>8264</td>\n", | |
" <td>60562.380782</td>\n", | |
" <td>-109957.035822</td>\n", | |
" <td>113</td>\n", | |
" <td>9.90</td>\n", | |
" <td>44597.53</td>\n", | |
" <td>203</td>\n", | |
" <td>92620.6</td>\n", | |
" <td>7051.4</td>\n", | |
" <td>2.971000</td>\n", | |
" <td>44561.744333</td>\n", | |
" <td>94054.175000</td>\n", | |
" <td>8360.895000</td>\n", | |
" <td>60565.804586</td>\n", | |
" <td>-109955.726165</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>90483903351</td>\n", | |
" <td>64317526813</td>\n", | |
" <td>4835175</td>\n", | |
" <td>2845975</td>\n", | |
" <td>7747</td>\n", | |
" <td>180296.700940</td>\n", | |
" <td>-327342.488095</td>\n", | |
" <td>23</td>\n", | |
" <td>47.39</td>\n", | |
" <td>132836.18</td>\n", | |
" <td>1174</td>\n", | |
" <td>271296.1</td>\n", | |
" <td>34833.4</td>\n", | |
" <td>27.033667</td>\n", | |
" <td>132699.947167</td>\n", | |
" <td>279290.253333</td>\n", | |
" <td>32820.870000</td>\n", | |
" <td>180311.488271</td>\n", | |
" <td>-327336.039663</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">12</th>\n", | |
" <th>0</th>\n", | |
" <td>62821234828</td>\n", | |
" <td>44275300633</td>\n", | |
" <td>3047650</td>\n", | |
" <td>2144367</td>\n", | |
" <td>11845</td>\n", | |
" <td>86824.031667</td>\n", | |
" <td>-157639.726688</td>\n", | |
" <td>23</td>\n", | |
" <td>0.00</td>\n", | |
" <td>63890.81</td>\n", | |
" <td>296</td>\n", | |
" <td>146573.1</td>\n", | |
" <td>13346.7</td>\n", | |
" <td>3.545000</td>\n", | |
" <td>63877.518500</td>\n", | |
" <td>134876.813333</td>\n", | |
" <td>12477.505000</td>\n", | |
" <td>86832.662961</td>\n", | |
" <td>-157636.090690</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>149116940556</td>\n", | |
" <td>105337208080</td>\n", | |
" <td>19037666</td>\n", | |
" <td>14110316</td>\n", | |
" <td>9700</td>\n", | |
" <td>211888.799499</td>\n", | |
" <td>-384709.742100</td>\n", | |
" <td>0</td>\n", | |
" <td>8.71</td>\n", | |
" <td>155994.05</td>\n", | |
" <td>1347</td>\n", | |
" <td>351273.7</td>\n", | |
" <td>44508.9</td>\n", | |
" <td>29.870500</td>\n", | |
" <td>155958.075333</td>\n", | |
" <td>327963.098333</td>\n", | |
" <td>38347.921667</td>\n", | |
" <td>211909.492590</td>\n", | |
" <td>-384700.571820</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">16</th>\n", | |
" <th>0</th>\n", | |
" <td>62090823955</td>\n", | |
" <td>43845420034</td>\n", | |
" <td>3611638</td>\n", | |
" <td>2702315</td>\n", | |
" <td>11854</td>\n", | |
" <td>86905.656130</td>\n", | |
" <td>-157787.722595</td>\n", | |
" <td>0</td>\n", | |
" <td>0.00</td>\n", | |
" <td>63887.42</td>\n", | |
" <td>297</td>\n", | |
" <td>144261.2</td>\n", | |
" <td>18152.8</td>\n", | |
" <td>3.545000</td>\n", | |
" <td>63935.821333</td>\n", | |
" <td>135050.745000</td>\n", | |
" <td>12487.290000</td>\n", | |
" <td>86914.305085</td>\n", | |
" <td>-157784.114143</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>146605495421</td>\n", | |
" <td>103525573447</td>\n", | |
" <td>13221402</td>\n", | |
" <td>8920160</td>\n", | |
" <td>9635</td>\n", | |
" <td>210300.517850</td>\n", | |
" <td>-381827.453760</td>\n", | |
" <td>212</td>\n", | |
" <td>37.29</td>\n", | |
" <td>154624.73</td>\n", | |
" <td>1338</td>\n", | |
" <td>349741.3</td>\n", | |
" <td>47315.2</td>\n", | |
" <td>29.578000</td>\n", | |
" <td>154786.471000</td>\n", | |
" <td>325649.420000</td>\n", | |
" <td>38054.253333</td>\n", | |
" <td>210321.074720</td>\n", | |
" <td>-381818.510432</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th rowspan=\"2\" valign=\"top\">20</th>\n", | |
" <th>0</th>\n", | |
" <td>62833925478</td>\n", | |
" <td>44360570828</td>\n", | |
" <td>3794434</td>\n", | |
" <td>2899374</td>\n", | |
" <td>11912</td>\n", | |
" <td>87313.016288</td>\n", | |
" <td>-158527.081652</td>\n", | |
" <td>0</td>\n", | |
" <td>0.00</td>\n", | |
" <td>64253.63</td>\n", | |
" <td>297</td>\n", | |
" <td>133315.7</td>\n", | |
" <td>14543.0</td>\n", | |
" <td>3.545000</td>\n", | |
" <td>64236.495167</td>\n", | |
" <td>135672.683333</td>\n", | |
" <td>12542.133333</td>\n", | |
" <td>87321.763664</td>\n", | |
" <td>-158523.406952</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>149039212896</td>\n", | |
" <td>105377515073</td>\n", | |
" <td>19895847</td>\n", | |
" <td>13695042</td>\n", | |
" <td>9675</td>\n", | |
" <td>211725.590392</td>\n", | |
" <td>-384413.544626</td>\n", | |
" <td>24</td>\n", | |
" <td>0.24</td>\n", | |
" <td>155757.97</td>\n", | |
" <td>1339</td>\n", | |
" <td>326903.8</td>\n", | |
" <td>39791.6</td>\n", | |
" <td>29.684333</td>\n", | |
" <td>155838.595500</td>\n", | |
" <td>327695.378333</td>\n", | |
" <td>38286.998333</td>\n", | |
" <td>211746.549918</td>\n", | |
" <td>-384404.509521</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" ENTRIESn EXITSn ENTRIESn_hourly EXITSn_hourly \\\n", | |
"hour weekday \n", | |
"0 0 63712687826 44939043396 3161210 2537164 \n", | |
" 1 153149943567 108048090886 7191957 5722665 \n", | |
"4 0 62392039290 44166326953 727273 734428 \n", | |
" 1 167128298182 117943547302 1573515 1479628 \n", | |
"8 0 30122489421 21296628669 363408 274662 \n", | |
" 1 90483903351 64317526813 4835175 2845975 \n", | |
"12 0 62821234828 44275300633 3047650 2144367 \n", | |
" 1 149116940556 105337208080 19037666 14110316 \n", | |
"16 0 62090823955 43845420034 3611638 2702315 \n", | |
" 1 146605495421 103525573447 13221402 8920160 \n", | |
"20 0 62833925478 44360570828 3794434 2899374 \n", | |
" 1 149039212896 105377515073 19895847 13695042 \n", | |
"\n", | |
" day_week latitude longitude fog precipi pressurei \\\n", | |
"hour weekday \n", | |
"0 0 11902 87231.063258 -158379.460616 0 0.00 64171.22 \n", | |
" 1 9752 213231.965466 -387148.771307 0 46.35 157011.83 \n", | |
"4 0 11887 87149.877929 -158231.085448 0 10.78 64104.73 \n", | |
" 1 9753 213435.880640 -387518.473888 24 36.28 157107.19 \n", | |
"8 0 8264 60562.380782 -109957.035822 113 9.90 44597.53 \n", | |
" 1 7747 180296.700940 -327342.488095 23 47.39 132836.18 \n", | |
"12 0 11845 86824.031667 -157639.726688 23 0.00 63890.81 \n", | |
" 1 9700 211888.799499 -384709.742100 0 8.71 155994.05 \n", | |
"16 0 11854 86905.656130 -157787.722595 0 0.00 63887.42 \n", | |
" 1 9635 210300.517850 -381827.453760 212 37.29 154624.73 \n", | |
"20 0 11912 87313.016288 -158527.081652 0 0.00 64253.63 \n", | |
" 1 9675 211725.590392 -384413.544626 24 0.24 155757.97 \n", | |
"\n", | |
" rain tempi wspdi meanprecipi meanpressurei \\\n", | |
"hour weekday \n", | |
"0 0 295 129012.7 9085.7 3.529000 64177.229333 \n", | |
" 1 1349 313620.2 30492.7 30.022000 156949.264167 \n", | |
"4 0 297 124710.4 8726.6 3.545000 64116.531333 \n", | |
" 1 1353 307984.3 27618.8 30.071500 157099.596833 \n", | |
"8 0 203 92620.6 7051.4 2.971000 44561.744333 \n", | |
" 1 1174 271296.1 34833.4 27.033667 132699.947167 \n", | |
"12 0 296 146573.1 13346.7 3.545000 63877.518500 \n", | |
" 1 1347 351273.7 44508.9 29.870500 155958.075333 \n", | |
"16 0 297 144261.2 18152.8 3.545000 63935.821333 \n", | |
" 1 1338 349741.3 47315.2 29.578000 154786.471000 \n", | |
"20 0 297 133315.7 14543.0 3.545000 64236.495167 \n", | |
" 1 1339 326903.8 39791.6 29.684333 155838.595500 \n", | |
"\n", | |
" meantempi meanwspdi weather_lat weather_lon \n", | |
"hour weekday \n", | |
"0 0 135503.341667 12522.123333 87239.766206 -158375.801147 \n", | |
" 1 329963.468333 38481.118333 213253.350657 -387139.695161 \n", | |
"4 0 135335.941667 12516.253333 87158.616124 -158227.501251 \n", | |
" 1 330257.781667 38569.438333 213457.281137 -387509.368133 \n", | |
"8 0 94054.175000 8360.895000 60565.804586 -109955.726165 \n", | |
" 1 279290.253333 32820.870000 180311.488271 -327336.039663 \n", | |
"12 0 134876.813333 12477.505000 86832.662961 -157636.090690 \n", | |
" 1 327963.098333 38347.921667 211909.492590 -384700.571820 \n", | |
"16 0 135050.745000 12487.290000 86914.305085 -157784.114143 \n", | |
" 1 325649.420000 38054.253333 210321.074720 -381818.510432 \n", | |
"20 0 135672.683333 12542.133333 87321.763664 -158523.406952 \n", | |
" 1 327695.378333 38286.998333 211746.549918 -384404.509521 " | |
] | |
}, | |
"execution_count": 54, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"ws=wp.sum()\n", | |
"ws" | |
] | |
}, | |
{ | |
"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.4.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment