Skip to content

Commit b65578f

Browse files
committed
Tweak section 3 for css changes
1 parent de859a9 commit b65578f

File tree

2 files changed

+344
-72
lines changed

2 files changed

+344
-72
lines changed

notebooks/3-data_visualization.ipynb

Lines changed: 161 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -229,22 +229,153 @@
229229
"source": [
230230
"### Line plots\n",
231231
"\n",
232-
"The `plot()` method will generate line plots for all numeric columns by default:"
232+
"Let's continue with the example of rolling and expanding calculations:"
233233
]
234234
},
235235
{
236236
"cell_type": "code",
237237
"execution_count": 3,
238+
"id": "2e6fc032-939f-4e3a-8cb7-ee57718f0c46",
239+
"metadata": {
240+
"editable": true,
241+
"slideshow": {
242+
"slide_type": ""
243+
},
244+
"tags": []
245+
},
246+
"outputs": [
247+
{
248+
"data": {
249+
"text/html": [
250+
"<div>\n",
251+
"<style scoped>\n",
252+
" .dataframe tbody tr th:only-of-type {\n",
253+
" vertical-align: middle;\n",
254+
" }\n",
255+
"\n",
256+
" .dataframe tbody tr th {\n",
257+
" vertical-align: top;\n",
258+
" }\n",
259+
"\n",
260+
" .dataframe thead th {\n",
261+
" text-align: right;\n",
262+
" }\n",
263+
"</style>\n",
264+
"<table border=\"1\" class=\"dataframe\">\n",
265+
" <thead>\n",
266+
" <tr style=\"text-align: right;\">\n",
267+
" <th></th>\n",
268+
" <th>travelers</th>\n",
269+
" <th>holiday</th>\n",
270+
" <th>7D MA</th>\n",
271+
" <th>YTD mean</th>\n",
272+
" </tr>\n",
273+
" <tr>\n",
274+
" <th>date</th>\n",
275+
" <th></th>\n",
276+
" <th></th>\n",
277+
" <th></th>\n",
278+
" <th></th>\n",
279+
" </tr>\n",
280+
" </thead>\n",
281+
" <tbody>\n",
282+
" <tr>\n",
283+
" <th>2020-01-01</th>\n",
284+
" <td>2311732.0</td>\n",
285+
" <td>New Year's Day</td>\n",
286+
" <td>2311732.0</td>\n",
287+
" <td>2311732.0</td>\n",
288+
" </tr>\n",
289+
" <tr>\n",
290+
" <th>2020-01-02</th>\n",
291+
" <td>2178656.0</td>\n",
292+
" <td>New Year's Day</td>\n",
293+
" <td>2245194.0</td>\n",
294+
" <td>2245194.0</td>\n",
295+
" </tr>\n",
296+
" <tr>\n",
297+
" <th>2020-01-03</th>\n",
298+
" <td>2422272.0</td>\n",
299+
" <td>NaN</td>\n",
300+
" <td>2304220.0</td>\n",
301+
" <td>2304220.0</td>\n",
302+
" </tr>\n",
303+
" <tr>\n",
304+
" <th>2020-01-04</th>\n",
305+
" <td>2210542.0</td>\n",
306+
" <td>NaN</td>\n",
307+
" <td>2280800.5</td>\n",
308+
" <td>2280800.5</td>\n",
309+
" </tr>\n",
310+
" <tr>\n",
311+
" <th>2020-01-05</th>\n",
312+
" <td>1806480.0</td>\n",
313+
" <td>NaN</td>\n",
314+
" <td>2185936.4</td>\n",
315+
" <td>2185936.4</td>\n",
316+
" </tr>\n",
317+
" </tbody>\n",
318+
"</table>\n",
319+
"</div>"
320+
],
321+
"text/plain": [
322+
" travelers holiday 7D MA YTD mean\n",
323+
"date \n",
324+
"2020-01-01 2311732.0 New Year's Day 2311732.0 2311732.0\n",
325+
"2020-01-02 2178656.0 New Year's Day 2245194.0 2245194.0\n",
326+
"2020-01-03 2422272.0 NaN 2304220.0 2304220.0\n",
327+
"2020-01-04 2210542.0 NaN 2280800.5 2280800.5\n",
328+
"2020-01-05 1806480.0 NaN 2185936.4 2185936.4"
329+
]
330+
},
331+
"execution_count": 3,
332+
"metadata": {},
333+
"output_type": "execute_result"
334+
}
335+
],
336+
"source": [
337+
"plot_data = tsa_melted_holiday_travel.drop(columns='year').loc['2020'].assign(\n",
338+
" **{\n",
339+
" '7D MA': lambda x: x.travelers.rolling('7D').mean(),\n",
340+
" 'YTD mean': lambda x: x.travelers.expanding().mean()\n",
341+
" }\n",
342+
")\n",
343+
"plot_data.head()"
344+
]
345+
},
346+
{
347+
"cell_type": "markdown",
348+
"id": "616bc44c-4c63-4d9a-9558-8f4de0b5b3e0",
349+
"metadata": {
350+
"editable": true,
351+
"slideshow": {
352+
"slide_type": "subslide"
353+
},
354+
"tags": []
355+
},
356+
"source": [
357+
"The `plot()` method will generate line plots for all numeric columns by default:"
358+
]
359+
},
360+
{
361+
"cell_type": "code",
362+
"execution_count": 4,
238363
"id": "7d30f224-a4c3-4083-981e-a3340f4a26b0",
239-
"metadata": {},
364+
"metadata": {
365+
"editable": true,
366+
"slideshow": {
367+
"slide_type": ""
368+
},
369+
"tags": []
370+
},
240371
"outputs": [
241372
{
242373
"data": {
243374
"text/plain": [
244375
"<Axes: title={'center': '2020 TSA Traveler Throughput'}, xlabel='date', ylabel='travelers'>"
245376
]
246377
},
247-
"execution_count": 3,
378+
"execution_count": 4,
248379
"metadata": {},
249380
"output_type": "execute_result"
250381
},
@@ -2135,12 +2266,7 @@
21352266
}
21362267
],
21372268
"source": [
2138-
"tsa_melted_holiday_travel.drop(columns='year').loc['2020'].assign(\n",
2139-
" **{\n",
2140-
" '7D MA': lambda x: x.travelers.rolling('7D').mean(),\n",
2141-
" 'YTD mean': lambda x: x.travelers.expanding().mean()\n",
2142-
" }\n",
2143-
").plot(title='2020 TSA Traveler Throughput', ylabel='travelers', alpha=0.8)"
2269+
"plot_data.plot(title='2020 TSA Traveler Throughput', ylabel='travelers', alpha=0.8)"
21442270
]
21452271
},
21462272
{
@@ -2173,7 +2299,7 @@
21732299
},
21742300
{
21752301
"cell_type": "code",
2176-
"execution_count": 4,
2302+
"execution_count": 5,
21772303
"id": "babbc6d8-fff4-4505-ad88-8af332416208",
21782304
"metadata": {},
21792305
"outputs": [
@@ -2254,7 +2380,7 @@
22542380
"5 74617773.0 7244733.0 NaN"
22552381
]
22562382
},
2257-
"execution_count": 4,
2383+
"execution_count": 5,
22582384
"metadata": {},
22592385
"output_type": "execute_result"
22602386
}
@@ -2281,17 +2407,17 @@
22812407
},
22822408
{
22832409
"cell_type": "code",
2284-
"execution_count": 5,
2410+
"execution_count": 6,
22852411
"id": "d1776fcf-d50f-44b1-8b11-26675347fec5",
22862412
"metadata": {},
22872413
"outputs": [
22882414
{
22892415
"data": {
22902416
"text/plain": [
2291-
"<matplotlib.legend.Legend at 0x117d8a960>"
2417+
"<matplotlib.legend.Legend at 0x12a5c6de0>"
22922418
]
22932419
},
2294-
"execution_count": 5,
2420+
"execution_count": 6,
22952421
"metadata": {},
22962422
"output_type": "execute_result"
22972423
},
@@ -3735,7 +3861,7 @@
37353861
},
37363862
{
37373863
"cell_type": "code",
3738-
"execution_count": 6,
3864+
"execution_count": 7,
37393865
"id": "5f2d78a2-ced4-48c2-b40c-993d72833828",
37403866
"metadata": {},
37413867
"outputs": [],
@@ -3758,7 +3884,7 @@
37583884
},
37593885
{
37603886
"cell_type": "code",
3761-
"execution_count": 7,
3887+
"execution_count": 8,
37623888
"id": "604d6112-2b33-403d-9383-982ab81e667c",
37633889
"metadata": {},
37643890
"outputs": [
@@ -5335,8 +5461,9 @@
53355461
"cell_type": "markdown",
53365462
"id": "b3baba7d-e807-4e33-9ccb-f21e62af9c1a",
53375463
"metadata": {
5464+
"editable": true,
53385465
"slideshow": {
5339-
"slide_type": "fragment"
5466+
"slide_type": "subslide"
53405467
},
53415468
"tags": []
53425469
},
@@ -5356,7 +5483,7 @@
53565483
},
53575484
{
53585485
"cell_type": "code",
5359-
"execution_count": 8,
5486+
"execution_count": 9,
53605487
"id": "243f8298-be40-4d6a-a4be-06abb85b0fa6",
53615488
"metadata": {},
53625489
"outputs": [],
@@ -5366,7 +5493,7 @@
53665493
},
53675494
{
53685495
"cell_type": "code",
5369-
"execution_count": 9,
5496+
"execution_count": 10,
53705497
"id": "7df8b0db-bda6-4a7f-bc63-18fa2a0304f2",
53715498
"metadata": {},
53725499
"outputs": [],
@@ -5376,7 +5503,7 @@
53765503
},
53775504
{
53785505
"cell_type": "code",
5379-
"execution_count": 10,
5506+
"execution_count": 11,
53805507
"id": "4bfc7ad9-ae6d-440e-b15f-eb3fa16d47ed",
53815508
"metadata": {},
53825509
"outputs": [],
@@ -5417,17 +5544,17 @@
54175544
},
54185545
{
54195546
"cell_type": "code",
5420-
"execution_count": 11,
5547+
"execution_count": 12,
54215548
"id": "b68a741f-9c37-4925-84b9-615c34ea0297",
54225549
"metadata": {},
54235550
"outputs": [
54245551
{
54255552
"data": {
54265553
"text/plain": [
5427-
"<seaborn.axisgrid.FacetGrid at 0x117e20980>"
5554+
"<seaborn.axisgrid.FacetGrid at 0x13f0592b0>"
54285555
]
54295556
},
5430-
"execution_count": 11,
5557+
"execution_count": 12,
54315558
"metadata": {},
54325559
"output_type": "execute_result"
54335560
},
@@ -6850,7 +6977,7 @@
68506977
},
68516978
{
68526979
"cell_type": "code",
6853-
"execution_count": 12,
6980+
"execution_count": 13,
68546981
"id": "46eafd2b-ffef-4aec-9a88-05342ac3fff6",
68556982
"metadata": {},
68566983
"outputs": [
@@ -6980,7 +7107,7 @@
69807107
"12 70219363.0 26391765.0 NaN"
69817108
]
69827109
},
6983-
"execution_count": 12,
7110+
"execution_count": 13,
69847111
"metadata": {},
69857112
"output_type": "execute_result"
69867113
}
@@ -6995,7 +7122,7 @@
69957122
},
69967123
{
69977124
"cell_type": "code",
6998-
"execution_count": 13,
7125+
"execution_count": 14,
69997126
"id": "efccdcd6-2a4f-4c20-856c-9b996da95935",
70007127
"metadata": {
70017128
"slideshow": {
@@ -8876,7 +9003,7 @@
88769003
},
88779004
{
88789005
"cell_type": "code",
8879-
"execution_count": 14,
9006+
"execution_count": 15,
88809007
"id": "e3379920-013d-4df5-9abc-b321060a6891",
88819008
"metadata": {},
88829009
"outputs": [],
@@ -8886,7 +9013,7 @@
88869013
},
88879014
{
88889015
"cell_type": "code",
8889-
"execution_count": 15,
9016+
"execution_count": 16,
88909017
"id": "0ec9abff-224b-49cb-ac0c-bd6955b5dcaf",
88919018
"metadata": {},
88929019
"outputs": [],
@@ -8896,7 +9023,7 @@
88969023
},
88979024
{
88989025
"cell_type": "code",
8899-
"execution_count": 16,
9026+
"execution_count": 17,
89009027
"id": "6d410276-25aa-4c16-9987-4e17930ebced",
89019028
"metadata": {},
89029029
"outputs": [],
@@ -8937,7 +9064,7 @@
89379064
},
89389065
{
89399066
"cell_type": "code",
8940-
"execution_count": 17,
9067+
"execution_count": 18,
89419068
"id": "681a84a7-6b72-4db8-bfd2-994f98b6494c",
89429069
"metadata": {},
89439070
"outputs": [
@@ -10357,7 +10484,7 @@
1035710484
},
1035810485
{
1035910486
"cell_type": "code",
10360-
"execution_count": 18,
10487+
"execution_count": 19,
1036110488
"id": "cd8a781f-3a17-445f-8ff2-742086122b67",
1036210489
"metadata": {},
1036310490
"outputs": [
@@ -12309,7 +12436,7 @@
1230912436
},
1231012437
{
1231112438
"cell_type": "code",
12312-
"execution_count": 19,
12439+
"execution_count": 20,
1231312440
"id": "583f952c-2c2e-40ed-9235-fd80a7fe43b7",
1231412441
"metadata": {},
1231512442
"outputs": [],
@@ -12319,7 +12446,7 @@
1231912446
},
1232012447
{
1232112448
"cell_type": "code",
12322-
"execution_count": 20,
12449+
"execution_count": 21,
1232312450
"id": "0b182f1a-33b0-4dde-9d54-e55d7bfeeae3",
1232412451
"metadata": {},
1232512452
"outputs": [],
@@ -12329,7 +12456,7 @@
1232912456
},
1233012457
{
1233112458
"cell_type": "code",
12332-
"execution_count": 21,
12459+
"execution_count": 22,
1233312460
"id": "07394de8-c5fa-4c90-ac5c-e5b6452838c7",
1233412461
"metadata": {},
1233512462
"outputs": [],

0 commit comments

Comments
 (0)