Skip to content

Commit 26f68e8

Browse files
committed
update exercise03 lesson7
1 parent a1b4d9a commit 26f68e8

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

lesson07/Exercise03/exercise03_solution.ipynb

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@
4242
"outputs": [],
4343
"source": [
4444
"# importing the necessary dependencies\n",
45-
"import numpy as np\n",
4645
"import pandas as pd"
4746
]
4847
},
4948
{
5049
"cell_type": "code",
51-
"execution_count": 12,
50+
"execution_count": 2,
5251
"metadata": {},
5352
"outputs": [
5453
{
@@ -57,7 +56,7 @@
5756
"\n",
5857
" <div class=\"bk-root\">\n",
5958
" <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
60-
" <span id=\"1265\">Loading BokehJS ...</span>\n",
59+
" <span id=\"1001\">Loading BokehJS ...</span>\n",
6160
" </div>"
6261
]
6362
},
@@ -226,7 +225,7 @@
226225
" \"</div>\"}};\n",
227226
"\n",
228227
" function display_loaded() {\n",
229-
" var el = document.getElementById(\"1265\");\n",
228+
" var el = document.getElementById(\"1001\");\n",
230229
" if (el != null) {\n",
231230
" el.textContent = \"BokehJS is loading...\";\n",
232231
" }\n",
@@ -280,9 +279,9 @@
280279
" console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
281280
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
282281
" }\n",
283-
" };var element = document.getElementById(\"1265\");\n",
282+
" };var element = document.getElementById(\"1001\");\n",
284283
" if (element == null) {\n",
285-
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1265' but no matching script tag was found. \")\n",
284+
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n",
286285
" return false;\n",
287286
" }\n",
288287
"\n",
@@ -319,7 +318,7 @@
319318
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
320319
" root._bokeh_failed_load = true;\n",
321320
" } else if (force !== true) {\n",
322-
" var cell = $(document.getElementById(\"1265\")).parents('.cell').data().cell;\n",
321+
" var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n",
323322
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
324323
" }\n",
325324
"\n",
@@ -336,7 +335,7 @@
336335
" }\n",
337336
"}(window));"
338337
],
339-
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"1265\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = js_urls.length;\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var s = document.createElement('script');\n s.src = url;\n s.async = false;\n s.onreadystatechange = s.onload = function() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: all BokehJS libraries loaded\");\n run_callbacks()\n }\n };\n s.onerror = function() {\n console.warn(\"failed to load library \" + url);\n };\n console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.getElementsByTagName(\"head\")[0].appendChild(s);\n }\n };var element = document.getElementById(\"1265\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1265' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.2.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"1265\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(js_urls, function() {\n console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
338+
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"1001\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = js_urls.length;\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var s = document.createElement('script');\n s.src = url;\n s.async = false;\n s.onreadystatechange = s.onload = function() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: all BokehJS libraries loaded\");\n run_callbacks()\n }\n };\n s.onerror = function() {\n console.warn(\"failed to load library \" + url);\n };\n console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.getElementsByTagName(\"head\")[0].appendChild(s);\n }\n };var element = document.getElementById(\"1001\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1001' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-1.0.2.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-1.0.2.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.2.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-1.0.2.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"1001\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(js_urls, function() {\n console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
340339
},
341340
"metadata": {},
342341
"output_type": "display_data"
@@ -351,7 +350,7 @@
351350
},
352351
{
353352
"cell_type": "code",
354-
"execution_count": 126,
353+
"execution_count": 3,
355354
"metadata": {},
356355
"outputs": [],
357356
"source": [
@@ -361,7 +360,7 @@
361360
},
362361
{
363362
"cell_type": "code",
364-
"execution_count": 127,
363+
"execution_count": 4,
365364
"metadata": {},
366365
"outputs": [
367366
{
@@ -465,7 +464,7 @@
465464
"4 1408600.0 "
466465
]
467466
},
468-
"execution_count": 127,
467+
"execution_count": 4,
469468
"metadata": {},
470469
"output_type": "execute_result"
471470
}
@@ -486,7 +485,7 @@
486485
},
487486
{
488487
"cell_type": "code",
489-
"execution_count": 128,
488+
"execution_count": 5,
490489
"metadata": {},
491490
"outputs": [],
492491
"source": [
@@ -516,7 +515,7 @@
516515
},
517516
{
518517
"cell_type": "code",
519-
"execution_count": 129,
518+
"execution_count": 6,
520519
"metadata": {},
521520
"outputs": [
522521
{
@@ -626,13 +625,13 @@
626625
"4 1408600.0 2016-01-11 "
627626
]
628627
},
629-
"execution_count": 129,
628+
"execution_count": 6,
630629
"metadata": {},
631630
"output_type": "execute_result"
632631
}
633632
],
634633
"source": [
635-
"# looking at the dataset with shortened dat\n",
634+
"# looking at the dataset with shortened date\n",
636635
"dataset.head()"
637636
]
638637
},
@@ -693,7 +692,7 @@
693692
},
694693
{
695694
"cell_type": "code",
696-
"execution_count": 261,
695+
"execution_count": 7,
697696
"metadata": {},
698697
"outputs": [],
699698
"source": [
@@ -703,13 +702,13 @@
703702
},
704703
{
705704
"cell_type": "code",
706-
"execution_count": 209,
705+
"execution_count": 8,
707706
"metadata": {},
708707
"outputs": [
709708
{
710709
"data": {
711710
"application/vnd.jupyter.widget-view+json": {
712-
"model_id": "6e896d554a6b4b5ebb119e96ed0f8ac3",
711+
"model_id": "854e4732261c4d28932aa6eca9fb19a0",
713712
"version_major": 2,
714713
"version_minor": 0
715714
},
@@ -733,19 +732,19 @@
733732
"metadata": {},
734733
"source": [
735734
"**Note:** \n",
736-
"`@interact()` is called a decorater which wraps the annotated method into the `interact` component which allows us to display and react on the change of the dropdown menu.\n",
737-
"The method will be exectued every time the value of the dropdown changes."
735+
"`@interact()` is called a decorator which wraps the annotated method into the `interact` component which allows us to display and react on the change of the dropdown menu.\n",
736+
"The method will be executed every time the value of the dropdown changes."
738737
]
739738
},
740739
{
741740
"cell_type": "code",
742-
"execution_count": 210,
741+
"execution_count": 9,
743742
"metadata": {},
744743
"outputs": [
745744
{
746745
"data": {
747746
"application/vnd.jupyter.widget-view+json": {
748-
"model_id": "9ea41fed737c479bb0d15070afddb21e",
747+
"model_id": "b01d8275673849dbae554ad7239fd157",
749748
"version_major": 2,
750749
"version_minor": 0
751750
},
@@ -768,13 +767,13 @@
768767
},
769768
{
770769
"cell_type": "code",
771-
"execution_count": 213,
770+
"execution_count": 10,
772771
"metadata": {},
773772
"outputs": [
774773
{
775774
"data": {
776775
"application/vnd.jupyter.widget-view+json": {
777-
"model_id": "71bec3439c2f43a5ae53e4d2eddc8970",
776+
"model_id": "932aab7752854b87a0471a763fc924b1",
778777
"version_major": 2,
779778
"version_minor": 0
780779
},
@@ -795,13 +794,13 @@
795794
},
796795
{
797796
"cell_type": "code",
798-
"execution_count": 259,
797+
"execution_count": 11,
799798
"metadata": {},
800799
"outputs": [
801800
{
802801
"data": {
803802
"application/vnd.jupyter.widget-view+json": {
804-
"model_id": "ff731fb2306149de9bc7fc48d73f1e74",
803+
"model_id": "b2eab044849f4f3fbe89fc58524b2feb",
805804
"version_major": 2,
806805
"version_minor": 0
807806
},
@@ -814,7 +813,7 @@
814813
}
815814
],
816815
"source": [
817-
"# multiple widets with custom layout\n",
816+
"# multiple widgets with default layout\n",
818817
"options=['Option1', 'Option2', 'Option3', 'Option4']\n",
819818
"\n",
820819
"@interact(Select=options, Display=False)\n",
@@ -824,13 +823,13 @@
824823
},
825824
{
826825
"cell_type": "code",
827-
"execution_count": 269,
826+
"execution_count": 12,
828827
"metadata": {},
829828
"outputs": [
830829
{
831830
"data": {
832831
"application/vnd.jupyter.widget-view+json": {
833-
"model_id": "c073f31f35f540ab8cfca5fdb2578b80",
832+
"model_id": "6edd31afff9e46f7aa5ff1509118775a",
834833
"version_major": 2,
835834
"version_minor": 0
836835
},
@@ -851,13 +850,13 @@
851850
},
852851
{
853852
"cell_type": "code",
854-
"execution_count": 270,
853+
"execution_count": 19,
855854
"metadata": {},
856855
"outputs": [
857856
{
858857
"data": {
859858
"application/vnd.jupyter.widget-view+json": {
860-
"model_id": "926ffa73828c44059dee4a1aa196c0ae",
859+
"model_id": "400e8326bfad43049994d8cb38e5f3a4",
861860
"version_major": 2,
862861
"version_minor": 0
863862
},
@@ -875,7 +874,7 @@
875874
"slider=IntSlider(min=0, max=100, continuous_update=False)\n",
876875
"\n",
877876
"@interact(Value=slider)\n",
878-
"def slider(Value=0.0):\n",
877+
"def slider(Value=0):\n",
879878
" print(Value)"
880879
]
881880
},
@@ -889,13 +888,13 @@
889888
},
890889
{
891890
"cell_type": "code",
892-
"execution_count": 260,
891+
"execution_count": 14,
893892
"metadata": {},
894893
"outputs": [
895894
{
896895
"data": {
897896
"application/vnd.jupyter.widget-view+json": {
898-
"model_id": "6cecc27cc0c44deca5de3f044bc7e80d",
897+
"model_id": "63440ff09c3f409d937f69a0f901cdf5",
899898
"version_major": 2,
900899
"version_minor": 0
901900
},
@@ -932,7 +931,8 @@
932931
"All of them can easily be integrated with your visualizations. In the next task, we'll take the dropdown widget to create a basic example on how to do this.\n",
933932
"\n",
934933
"> A full list of the functionality for the widgets can be found here: \n",
935-
"https://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html"
934+
"https://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html\n",
935+
"https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html"
936936
]
937937
},
938938
{
@@ -960,7 +960,7 @@
960960
},
961961
{
962962
"cell_type": "code",
963-
"execution_count": 184,
963+
"execution_count": 15,
964964
"metadata": {},
965965
"outputs": [],
966966
"source": [
@@ -980,7 +980,7 @@
980980
},
981981
{
982982
"cell_type": "code",
983-
"execution_count": 180,
983+
"execution_count": 16,
984984
"metadata": {},
985985
"outputs": [],
986986
"source": [
@@ -1021,7 +1021,7 @@
10211021
},
10221022
{
10231023
"cell_type": "code",
1024-
"execution_count": 181,
1024+
"execution_count": 17,
10251025
"metadata": {},
10261026
"outputs": [],
10271027
"source": [
@@ -1031,13 +1031,13 @@
10311031
},
10321032
{
10331033
"cell_type": "code",
1034-
"execution_count": 183,
1034+
"execution_count": 18,
10351035
"metadata": {},
10361036
"outputs": [
10371037
{
10381038
"data": {
10391039
"application/vnd.jupyter.widget-view+json": {
1040-
"model_id": "e95c692df0af439ebb806b5d9779082f",
1040+
"model_id": "bbd09530a6014b5a9f125d3f96f95207",
10411041
"version_major": 2,
10421042
"version_minor": 0
10431043
},

0 commit comments

Comments
 (0)