diff --git a/Assignment1/Assignment1.ipynb b/Assignment1/Assignment1.ipynb index ca49c32..faf6fda 100644 --- a/Assignment1/Assignment1.ipynb +++ b/Assignment1/Assignment1.ipynb @@ -22,12 +22,16 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 1, "id": "fcf3beb9", "metadata": {}, "outputs": [], "source": [ - "#%pip install pandas seaborn matplotlib bokeh ftfy geopandas jupyter_bokeh\n", + "# Uncomment the line below to install the exact dependency versions used to run this notebook\n", + "\n", + "#%pip install --force-reinstall bokeh==3.1.0 ftfy==6.1.1 geopandas==0.12.2 matplotlib==3.7.1 numpy==1.24.2 pandas==1.5.3 seaborn==0.12.2 Shapely==2.0.1\n", + "\n", + "# Due to the embedded bokeh cloropleth map, Jupyter-lab web version is required to run and show this notebook.\n", "\n", "import pandas as pd\n", "import numpy as np\n", @@ -42,6 +46,27 @@ "from bokeh.layouts import gridplot, column, row" ] }, + { + "cell_type": "code", + "execution_count": 2, + "id": "9e3728c5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3.10.10 (main, Feb 16 2023, 02:55:02) [Clang 14.0.0 (clang-1400.0.29.202)]\n" + ] + } + ], + "source": [ + "# Show python version used to run this notebook\n", + "import sys\n", + "\n", + "print(sys.version)" + ] + }, { "cell_type": "markdown", "id": "6f271000", @@ -56,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "a0af6847", "metadata": {}, "outputs": [ @@ -66,7 +91,7 @@ "('Ü', 'sloppy-windows-1252')" ] }, - "execution_count": 2, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -78,7 +103,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "22ce9426", "metadata": {}, "outputs": [ @@ -275,7 +300,7 @@ "4 2016-03-31 00:00:00 0 60437 2016-04-06 10:17:21 " ] }, - "execution_count": 3, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -288,7 +313,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "a332b6a5", "metadata": {}, "outputs": [ @@ -317,7 +342,7 @@ " 'lastSeen': ['str']}" ] }, - "execution_count": 4, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -335,7 +360,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "11bfa9a2", "metadata": {}, "outputs": [ @@ -376,7 +401,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "f1c539c4", "metadata": {}, "outputs": [ @@ -417,7 +442,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "86074e70", "metadata": {}, "outputs": [ @@ -614,7 +639,7 @@ "4 2016-03-31 00:00:00 0 60437 2016-04-06 10:17:21 " ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -656,7 +681,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "id": "8b6f9ce3", "metadata": {}, "outputs": [ @@ -686,7 +711,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "id": "98f8d101", "metadata": {}, "outputs": [ @@ -711,7 +736,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "id": "f300f49d", "metadata": {}, "outputs": [ @@ -730,7 +755,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "id": "923c5354", "metadata": {}, "outputs": [], @@ -741,7 +766,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "id": "4b847b1f", "metadata": {}, "outputs": [], @@ -752,7 +777,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "id": "bf1f417d", "metadata": {}, "outputs": [ @@ -782,7 +807,7 @@ "dtype: int64" ] }, - "execution_count": 13, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -794,7 +819,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "id": "919e692f", "metadata": {}, "outputs": [], @@ -837,7 +862,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "id": "7cc5c90f", "metadata": {}, "outputs": [ @@ -898,7 +923,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "id": "ca97e7c8", "metadata": {}, "outputs": [ @@ -982,7 +1007,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "id": "eb956ed4", "metadata": {}, "outputs": [], @@ -1003,7 +1028,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "id": "4a29684b", "metadata": {}, "outputs": [], @@ -1013,7 +1038,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "id": "d3d58d25", "metadata": {}, "outputs": [ @@ -1077,7 +1102,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 21, "id": "b4fde7e4", "metadata": {}, "outputs": [], @@ -1088,7 +1113,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 22, "id": "25391739", "metadata": {}, "outputs": [], @@ -1134,7 +1159,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 23, "id": "f8906707", "metadata": {}, "outputs": [ @@ -1244,7 +1269,7 @@ "Angola 51.666667 0.0 " ] }, - "execution_count": 22, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -1272,7 +1297,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 24, "id": "a677ce07", "metadata": {}, "outputs": [ @@ -1414,7 +1439,7 @@ " Cameroon 339 84.750000 " ] }, - "execution_count": 23, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -1439,7 +1464,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 25, "id": "a29b8c2f", "metadata": {}, "outputs": [ @@ -1508,7 +1533,7 @@ }, { "cell_type": "code", - "execution_count": 194, + "execution_count": 26, "id": "5d1fad2a", "metadata": {}, "outputs": [ @@ -1532,7 +1557,7 @@ "\n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -1556,7 +1581,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -1648,7 +1673,7 @@ " \n", " \n", " \n", - " \n", + " \n", " \n", " \n", " \n", @@ -1694,8 +1719,8 @@ " \n", " \n", " \n", - " \n", - " \n", + " \n", + " \n", " \n", " \n", " \n", @@ -1707,42 +1732,42 @@ "" ], "text/plain": [ - "country Albania Andorra Austria Belarus Belgium \\\n", - "country_dest \n", + "country_dest Albania Andorra Austria Belarus Belgium \\\n", + "country \n", "Albania 0.0 0.0 1.0 0.0 0.0 \n", "Andorra 0.0 0.0 0.0 0.0 0.0 \n", "Austria 1.0 0.0 15.0 2.0 2.0 \n", "Belarus 0.0 0.0 2.0 0.0 0.0 \n", "Belgium 0.0 0.0 2.0 0.0 1.0 \n", "\n", - "country Bosnia and Herzegovina Bulgaria Croatia Czech Republic \\\n", - "country_dest \n", + "country_dest Bosnia and Herzegovina Bulgaria Croatia Czech Republic \\\n", + "country \n", "Albania 0.0 0.0 0.0 0.0 \n", "Andorra 0.0 0.0 0.0 0.0 \n", "Austria 1.0 3.0 6.0 1.0 \n", "Belarus 0.0 0.0 0.0 2.0 \n", "Belgium 0.0 4.0 5.0 4.0 \n", "\n", - "country Denmark ... San Marino Serbia Slovakia Slovenia Spain \\\n", - "country_dest ... \n", + "country_dest Denmark ... San Marino Serbia Slovakia Slovenia Spain \\\n", + "country ... \n", "Albania 0.0 ... 0.0 0.0 0.0 1.0 0.0 \n", "Andorra 0.0 ... 0.0 0.0 0.0 0.0 0.0 \n", "Austria 5.0 ... 0.0 3.0 1.0 2.0 40.0 \n", "Belarus 0.0 ... 0.0 0.0 0.0 0.0 1.0 \n", - "Belgium 5.0 ... 0.0 2.0 1.0 3.0 60.0 \n", + "Belgium 5.0 ... 0.0 2.0 1.0 3.0 57.0 \n", "\n", - "country Sweden Switzerland Ukraine United Kingdom Vatican City \n", - "country_dest \n", + "country_dest Sweden Switzerland Ukraine United Kingdom Vatican City \n", + "country \n", "Albania 0.0 0.0 0.0 1.0 0.0 \n", "Andorra 0.0 0.0 0.0 0.0 0.0 \n", - "Austria 4.0 11.0 10.0 11.0 0.0 \n", + "Austria 4.0 12.0 10.0 11.0 0.0 \n", "Belarus 1.0 1.0 2.0 1.0 0.0 \n", - "Belgium 6.0 6.0 2.0 17.0 0.0 \n", + "Belgium 7.0 6.0 2.0 17.0 0.0 \n", "\n", "[5 rows x 46 columns]" ] }, - "execution_count": 194, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -1751,6 +1776,7 @@ "df_air = pd.read_csv(\"./datasets/airports.csv\", index_col='ID', na_values=['\\\\N'], dtype={'ID': pd.Int64Dtype()}) \\\n", " .drop(columns=['latitude', 'longitude'])\n", "\n", + "# I am assuming each row of this data source should be counted as one flight\n", "df_routes = pd.read_csv(\"./datasets/routes.csv\", na_values=['\\\\N'], sep=\";\") \\\n", " .rename(lambda x: x.strip(), axis=1)\n", "\n", @@ -1759,6 +1785,7 @@ "df_countries = df_countries.loc[df_countries.continent == 'eu', :] \\\n", " .rename(columns={'name': 'country'}).drop(columns=['continent'])\n", "\n", + "# This is the only country that has a different name in countries.csv compared to airports.csv\n", "df_countries.loc[df_countries.country == 'Faroe Is.', 'country'] = 'Faroe Islands'\n", "\n", "df_id_country = df_air.join(df_countries.set_index('country'), on='country', how='right', lsuffix='_air') \\\n", @@ -1768,6 +1795,12 @@ "\n", "# Right join twice with source airport country and destination airport country\n", "# A right join assures we include all countries in the final dataframe\n", + "\n", + "# Note that I join on IATA codes instead of airport IDs as some airports have missing IDs. \n", + "# This SHOULD be fine for the scope of this assignment, however on a worldwide scale IDs are\n", + "# preferrable as IATA codes may have overlaps. The author of this notebook advocates for the use\n", + "# of ICAO codes in datasets and to follow ISO and UN recommendations whenever practical, however this \n", + "# is just my cup of ISO 3103.\n", "df_routes_count = df_routes \\\n", " .loc[:, ['source_airport', 'destination_airport']] \\\n", " .join(df_id_country, how='right', on='source_airport') \\\n", @@ -1781,13 +1814,13 @@ "df_routes_count.loc[df_routes_count.source_airport.notna() & \\\n", " df_routes_count.destination_airport.notna(), '# routes'] = 1\n", "\n", - "# destination as rows, source as columns\n", + "# source of flights as rows, destination as columns\n", "df_routes_count = df_routes_count \\\n", - " .groupby(['country_dest', 'country']).agg({'# routes': 'sum'}) \\\n", + " .groupby(['country', 'country_dest']).agg({'# routes': 'sum'}) \\\n", " .rename(columns={0: '# routes'}) \\\n", " .unstack() \\\n", " .fillna(0) \\\n", - " .sort_values('country_dest')\n", + " .sort_values('country')\n", "\n", "# Change type of cells to float and remove column level for geopandas compatibility\n", "df_routes_count = df_routes_count[df_routes_count.columns].astype(float)\n", @@ -1797,7 +1830,7 @@ }, { "cell_type": "code", - "execution_count": 195, + "execution_count": 27, "id": "87bd101d", "metadata": {}, "outputs": [ @@ -2003,7 +2036,7 @@ "[5 rows x 48 columns]" ] }, - "execution_count": 195, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -2022,19 +2055,326 @@ }, { "cell_type": "code", - "execution_count": 218, + "execution_count": 28, "id": "11612845", "metadata": {}, "outputs": [ + { + "data": { + "text/html": [ + "\n", + "
\n", + " \n", + " Loading BokehJS ...\n", + "
\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/javascript": [ + "(function(root) {\n", + " function now() {\n", + " return new Date();\n", + " }\n", + "\n", + " const 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", + "const JS_MIME_TYPE = 'application/javascript';\n", + " const HTML_MIME_TYPE = 'text/html';\n", + " const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", + " const CLASS_NAME = 'output_bokeh rendered_html';\n", + "\n", + " /**\n", + " * Render data to the DOM node\n", + " */\n", + " function render(props, node) {\n", + " const script = document.createElement(\"script\");\n", + " node.appendChild(script);\n", + " }\n", + "\n", + " /**\n", + " * Handle when an output is cleared or removed\n", + " */\n", + " function handleClearOutput(event, handle) {\n", + " const cell = handle.cell;\n", + "\n", + " const id = cell.output_area._bokeh_element_id;\n", + " const server_id = cell.output_area._bokeh_server_id;\n", + " // Clean up Bokeh references\n", + " if (id != null && id in Bokeh.index) {\n", + " Bokeh.index[id].model.document.clear();\n", + " delete Bokeh.index[id];\n", + " }\n", + "\n", + " if (server_id !== undefined) {\n", + " // Clean up Bokeh references\n", + " const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", + " cell.notebook.kernel.execute(cmd_clean, {\n", + " iopub: {\n", + " output: function(msg) {\n", + " const id = msg.content.text.trim();\n", + " if (id in Bokeh.index) {\n", + " Bokeh.index[id].model.document.clear();\n", + " delete Bokeh.index[id];\n", + " }\n", + " }\n", + " }\n", + " });\n", + " // Destroy server and session\n", + " const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", + " cell.notebook.kernel.execute(cmd_destroy);\n", + " }\n", + " }\n", + "\n", + " /**\n", + " * Handle when a new output is added\n", + " */\n", + " function handleAddOutput(event, handle) {\n", + " const output_area = handle.output_area;\n", + " const output = handle.output;\n", + "\n", + " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", + " if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n", + " return\n", + " }\n", + "\n", + " const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", + "\n", + " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", + " toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n", + " // store reference to embed id on output_area\n", + " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", + " }\n", + " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", + " const bk_div = document.createElement(\"div\");\n", + " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", + " const script_attrs = bk_div.children[0].attributes;\n", + " for (let i = 0; i < script_attrs.length; i++) {\n", + " toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", + " toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n", + " }\n", + " // store reference to server id on output_area\n", + " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", + " }\n", + " }\n", + "\n", + " function register_renderer(events, OutputArea) {\n", + "\n", + " function append_mime(data, metadata, element) {\n", + " // create a DOM node to render to\n", + " const toinsert = this.create_output_subarea(\n", + " metadata,\n", + " CLASS_NAME,\n", + " EXEC_MIME_TYPE\n", + " );\n", + " this.keyboard_manager.register_events(toinsert);\n", + " // Render to node\n", + " const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", + " render(props, toinsert[toinsert.length - 1]);\n", + " element.append(toinsert);\n", + " return toinsert\n", + " }\n", + "\n", + " /* Handle when an output is cleared or removed */\n", + " events.on('clear_output.CodeCell', handleClearOutput);\n", + " events.on('delete.Cell', handleClearOutput);\n", + "\n", + " /* Handle when a new output is added */\n", + " events.on('output_added.OutputArea', handleAddOutput);\n", + "\n", + " /**\n", + " * Register the mime type and append_mime function with output_area\n", + " */\n", + " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", + " /* Is output safe? */\n", + " safe: true,\n", + " /* Index of renderer in `output_area.display_order` */\n", + " index: 0\n", + " });\n", + " }\n", + "\n", + " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", + " if (root.Jupyter !== undefined) {\n", + " const events = require('base/js/events');\n", + " const OutputArea = require('notebook/js/outputarea').OutputArea;\n", + "\n", + " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", + " register_renderer(events, OutputArea);\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", + " const NB_LOAD_WARNING = {'data': {'text/html':\n", + " \"
\\n\"+\n", + " \"

\\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", + " \"

\\n\"+\n", + " \"\\n\"+\n", + " \"\\n\"+\n", + " \"from bokeh.resources import INLINE\\n\"+\n", + " \"output_notebook(resources=INLINE)\\n\"+\n", + " \"\\n\"+\n", + " \"
\"}};\n", + "\n", + " function display_loaded() {\n", + " const el = document.getElementById(\"p1001\");\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", + " function run_callbacks() {\n", + " try {\n", + " root._bokeh_onload_callbacks.forEach(function(callback) {\n", + " if (callback != null)\n", + " callback();\n", + " });\n", + " } finally {\n", + " delete root._bokeh_onload_callbacks\n", + " }\n", + " console.debug(\"Bokeh: all callbacks have finished\");\n", + " }\n", + "\n", + " function load_libs(css_urls, js_urls, callback) {\n", + " if (css_urls == null) css_urls = [];\n", + " if (js_urls == null) js_urls = [];\n", + "\n", + " root._bokeh_onload_callbacks.push(callback);\n", + " if (root._bokeh_is_loading > 0) {\n", + " console.debug(\"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.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", + " root._bokeh_is_loading = css_urls.length + js_urls.length;\n", + "\n", + " function on_load() {\n", + " root._bokeh_is_loading--;\n", + " if (root._bokeh_is_loading === 0) {\n", + " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", + " run_callbacks()\n", + " }\n", + " }\n", + "\n", + " function on_error(url) {\n", + " console.error(\"failed to load \" + url);\n", + " }\n", + "\n", + " for (let i = 0; i < css_urls.length; i++) {\n", + " const url = css_urls[i];\n", + " const element = document.createElement(\"link\");\n", + " element.onload = on_load;\n", + " element.onerror = on_error.bind(null, url);\n", + " element.rel = \"stylesheet\";\n", + " element.type = \"text/css\";\n", + " element.href = url;\n", + " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", + " document.body.appendChild(element);\n", + " }\n", + "\n", + " for (let i = 0; i < js_urls.length; i++) {\n", + " const url = js_urls[i];\n", + " const element = document.createElement('script');\n", + " element.onload = on_load;\n", + " element.onerror = on_error.bind(null, url);\n", + " element.async = false;\n", + " element.src = url;\n", + " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", + " document.head.appendChild(element);\n", + " }\n", + " };\n", + "\n", + " function inject_raw_css(css) {\n", + " const element = document.createElement(\"style\");\n", + " element.appendChild(document.createTextNode(css));\n", + " document.body.appendChild(element);\n", + " }\n", + "\n", + " const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.1.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.1.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.1.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.1.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.1.0.min.js\"];\n", + " const css_urls = [];\n", + "\n", + " const inline_js = [ function(Bokeh) {\n", + " Bokeh.set_log_level(\"info\");\n", + " },\n", + "function(Bokeh) {\n", + " }\n", + " ];\n", + "\n", + " function run_inline_js() {\n", + " if (root.Bokeh !== undefined || force === true) {\n", + " for (let i = 0; i < inline_js.length; i++) {\n", + " inline_js[i].call(root, root.Bokeh);\n", + " }\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", + " const cell = $(document.getElementById(\"p1001\")).parents('.cell').data().cell;\n", + " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", + " }\n", + " }\n", + "\n", + " if (root._bokeh_is_loading === 0) {\n", + " console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", + " run_inline_js();\n", + " } else {\n", + " load_libs(css_urls, js_urls, function() {\n", + " console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n", + " run_inline_js();\n", + " });\n", + " }\n", + "}(window));" + ], + "application/vnd.bokehjs_load.v0+json": "(function(root) {\n function now() {\n return new Date();\n }\n\n const 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 if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\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 \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded() {\n const el = document.getElementById(\"p1001\");\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 function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"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.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.1.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.1.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.1.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.1.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.1.0.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\nif (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 const cell = $(document.getElementById(\"p1001\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" + }, + "metadata": {}, + "output_type": "display_data" + }, { "data": { "application/vnd.bokehjs_exec.v0+json": "", "text/html": [ - "
countrycountry_destAlbaniaAndorraAustriaVatican City
country_destcountry2.040.04.011.012.010.011.00.02.01.03.060.06.057.07.06.02.017.0