{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Reshaping data frames by stacking and unstacking\n", "\n", "[Data set download](https://s3.amazonaws.com/bebi103.caltech.edu/data/penguins_subset.csv)\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "nbsphinx": "hidden", "tags": [] }, "outputs": [], "source": [ "# Colab setup ------------------\n", "import os, sys, subprocess\n", "if \"google.colab\" in sys.modules:\n", " cmd = \"pip install --upgrade iqplot bebi103 iqplot watermark\"\n", " process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n", " stdout, stderr = process.communicate()\n", " data_path = \"https://s3.amazonaws.com/bebi103.caltech.edu/data/\"\n", "else:\n", " data_path = \"../data/\"" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\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(\"1002\");\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-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.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(\"1002\")).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(\"1002\");\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-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.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(\"1002\")).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" } ], "source": [ "import pandas as pd\n", "\n", "import iqplot\n", "\n", "import bokeh.io\n", "bokeh.io.output_notebook()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "We have seen how melting a data frame can bring it to tidy format, but this is not always the best option. **Stacking** and **unstacking** operations can be very useful for shaping data frames. As usual, this is best seen by example, and we will use a subset of the [Palmer penguins data set](https://towardsdatascience.com/penguins-dataset-overview-iris-alternative-9453bb8c8d95), which you can download here: [https://s3.amazonaws.com/bebi103.caltech.edu/data/penguins_subset.csv](https://s3.amazonaws.com/bebi103.caltech.edu/data/penguins_subset.csv). The data set consists of measurements of three different species of penguins acquired at the [Palmer Station in Antarctica](https://en.wikipedia.org/wiki/Palmer_Station). The measurements were made between 2007 and 2009 by [Kristen Gorman](https://www.uaf.edu/cfos/people/faculty/detail/kristen-gorman.php)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Melting the data set too soon\n", "\n", "We start by loading in the data set, bearing in mind that for this particular format of it the header rows are rows zero and one." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
GentooAdelieChinstrap
bill_depth_mmbill_length_mmflipper_length_mmbody_mass_gbill_depth_mmbill_length_mmflipper_length_mmbody_mass_gbill_depth_mmbill_length_mmflipper_length_mmbody_mass_g
016.348.4220.05400.018.536.8193.03500.018.347.6195.03850.0
115.846.3215.05050.016.937.0185.03000.016.742.5187.03350.0
214.247.5209.04600.019.542.0200.04050.016.640.9187.03200.0
315.748.7208.05350.018.342.7196.04075.020.052.8205.04550.0
414.148.7210.04450.018.035.7202.03550.018.745.4188.03525.0
\n", "
" ], "text/plain": [ " Gentoo Adelie \\\n", " bill_depth_mm bill_length_mm flipper_length_mm body_mass_g bill_depth_mm \n", "0 16.3 48.4 220.0 5400.0 18.5 \n", "1 15.8 46.3 215.0 5050.0 16.9 \n", "2 14.2 47.5 209.0 4600.0 19.5 \n", "3 15.7 48.7 208.0 5350.0 18.3 \n", "4 14.1 48.7 210.0 4450.0 18.0 \n", "\n", " Chinstrap \\\n", " bill_length_mm flipper_length_mm body_mass_g bill_depth_mm bill_length_mm \n", "0 36.8 193.0 3500.0 18.3 47.6 \n", "1 37.0 185.0 3000.0 16.7 42.5 \n", "2 42.0 200.0 4050.0 16.6 40.9 \n", "3 42.7 196.0 4075.0 20.0 52.8 \n", "4 35.7 202.0 3550.0 18.7 45.4 \n", "\n", " \n", " flipper_length_mm body_mass_g \n", "0 195.0 3850.0 \n", "1 187.0 3350.0 \n", "2 187.0 3200.0 \n", "3 205.0 4550.0 \n", "4 188.0 3525.0 " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(os.path.join(data_path, \"penguins_subset.csv\"), header=[0, 1])\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We have a multiindex for the column names. This data set is not tidy because each row corresponds to observations of three different penguins. To tidy it, we could go ahead and melt it.\n", "\n", "To ease melting and further analysis, I will do what I always do when I have a multiindex; I will name the levels of the index." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
speciesGentooAdelieChinstrap
propertybill_depth_mmbill_length_mmflipper_length_mmbody_mass_gbill_depth_mmbill_length_mmflipper_length_mmbody_mass_gbill_depth_mmbill_length_mmflipper_length_mmbody_mass_g
016.348.4220.05400.018.536.8193.03500.018.347.6195.03850.0
115.846.3215.05050.016.937.0185.03000.016.742.5187.03350.0
214.247.5209.04600.019.542.0200.04050.016.640.9187.03200.0
315.748.7208.05350.018.342.7196.04075.020.052.8205.04550.0
414.148.7210.04450.018.035.7202.03550.018.745.4188.03525.0
\n", "
" ], "text/plain": [ "species Gentoo \\\n", "property bill_depth_mm bill_length_mm flipper_length_mm body_mass_g \n", "0 16.3 48.4 220.0 5400.0 \n", "1 15.8 46.3 215.0 5050.0 \n", "2 14.2 47.5 209.0 4600.0 \n", "3 15.7 48.7 208.0 5350.0 \n", "4 14.1 48.7 210.0 4450.0 \n", "\n", "species Adelie \\\n", "property bill_depth_mm bill_length_mm flipper_length_mm body_mass_g \n", "0 18.5 36.8 193.0 3500.0 \n", "1 16.9 37.0 185.0 3000.0 \n", "2 19.5 42.0 200.0 4050.0 \n", "3 18.3 42.7 196.0 4075.0 \n", "4 18.0 35.7 202.0 3550.0 \n", "\n", "species Chinstrap \n", "property bill_depth_mm bill_length_mm flipper_length_mm body_mass_g \n", "0 18.3 47.6 195.0 3850.0 \n", "1 16.7 42.5 187.0 3350.0 \n", "2 16.6 40.9 187.0 3200.0 \n", "3 20.0 52.8 205.0 4550.0 \n", "4 18.7 45.4 188.0 3525.0 " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.columns.names = [\"species\", \"property\"]\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are now ready for a melt. Because we have names for the levels of our multiindex, the melt function will automatically name the columns of the resulting melted data frame." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
speciespropertyvalue
0Gentoobill_depth_mm16.3
1Gentoobill_depth_mm15.8
2Gentoobill_depth_mm14.2
3Gentoobill_depth_mm15.7
4Gentoobill_depth_mm14.1
\n", "
" ], "text/plain": [ " species property value\n", "0 Gentoo bill_depth_mm 16.3\n", "1 Gentoo bill_depth_mm 15.8\n", "2 Gentoo bill_depth_mm 14.2\n", "3 Gentoo bill_depth_mm 15.7\n", "4 Gentoo bill_depth_mm 14.1" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_melted = df.melt()\n", "\n", "df_melted.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This seems like a tidy data frame, and it is, but we have lost information! Specifically, we lost the which individual penguin each measurements belongs to. A total of 204 penguins were measured (68 for each species), and four properties of each were measured. The melted data frame has 204 × 4 = 816 rows. This is no good, since we want to know which penguin each _set_ of four measurements belongs to.\n", "\n", "So, we want a tidy data frame that has five columns, each column containing a variable for one set of measurements. The variables are the beak depth, beak length, flipper length, and weight, and which species the penguin being measured is." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Stacking\n", "\n", "**Stacking** is procedure that takes a wide data frame and makes it narrower by converting the names at a level of a columnar multiindex into an index in the data frame. In this case, we want to make the species, as given in the top level of the column muliindex, and make it an index. Let's perform the stacking operation and see what we get." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
propertybill_depth_mmbill_length_mmbody_mass_gflipper_length_mm
species
0Adelie18.536.83500.0193.0
Chinstrap18.347.63850.0195.0
Gentoo16.348.45400.0220.0
1Adelie16.937.03000.0185.0
Chinstrap16.742.53350.0187.0
\n", "
" ], "text/plain": [ "property bill_depth_mm bill_length_mm body_mass_g flipper_length_mm\n", " species \n", "0 Adelie 18.5 36.8 3500.0 193.0\n", " Chinstrap 18.3 47.6 3850.0 195.0\n", " Gentoo 16.3 48.4 5400.0 220.0\n", "1 Adelie 16.9 37.0 3000.0 185.0\n", " Chinstrap 16.7 42.5 3350.0 187.0" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.stack(level=\"species\")\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now have a multiindex for the data frame index. The outer index is nameless and the inner index carries the name \"species\". We no longer have a multiindex for the column names, but have the sets of columns we like.\n", "\n", "This structure of the data frame makes sense, but it would be easier to understand if we swapped the levels of the index." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
propertybill_depth_mmbill_length_mmbody_mass_gflipper_length_mm
species
Adelie018.536.83500.0193.0
Chinstrap018.347.63850.0195.0
Gentoo016.348.45400.0220.0
Adelie116.937.03000.0185.0
Chinstrap116.742.53350.0187.0
\n", "
" ], "text/plain": [ "property bill_depth_mm bill_length_mm body_mass_g flipper_length_mm\n", "species \n", "Adelie 0 18.5 36.8 3500.0 193.0\n", "Chinstrap 0 18.3 47.6 3850.0 195.0\n", "Gentoo 0 16.3 48.4 5400.0 220.0\n", "Adelie 1 16.9 37.0 3000.0 185.0\n", "Chinstrap 1 16.7 42.5 3350.0 187.0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.swaplevel(axis=\"index\")\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, the second index is the measurement number for a given species. It becomes easier to understand if we provide a name for the inner index and sort by species." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
propertybill_depth_mmbill_length_mmbody_mass_gflipper_length_mm
speciespenguin number
Adelie018.536.83500.0193.0
116.937.03000.0185.0
219.542.04050.0200.0
318.342.74075.0196.0
418.035.73550.0202.0
\n", "
" ], "text/plain": [ "property bill_depth_mm bill_length_mm body_mass_g \\\n", "species penguin number \n", "Adelie 0 18.5 36.8 3500.0 \n", " 1 16.9 37.0 3000.0 \n", " 2 19.5 42.0 4050.0 \n", " 3 18.3 42.7 4075.0 \n", " 4 18.0 35.7 3550.0 \n", "\n", "property flipper_length_mm \n", "species penguin number \n", "Adelie 0 193.0 \n", " 1 185.0 \n", " 2 200.0 \n", " 3 196.0 \n", " 4 202.0 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.index.names = [\"species\", \"penguin number\"]\n", "df = df.sort_index(level=\"species\")\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "However, if we want to make a plot out of this, we need to convert the row index to columns of the data frame, which we can do with the `reset_index()` method." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
propertyspeciespenguin numberbill_depth_mmbill_length_mmbody_mass_gflipper_length_mm
0Adelie018.536.83500.0193.0
1Adelie116.937.03000.0185.0
2Adelie219.542.04050.0200.0
3Adelie318.342.74075.0196.0
4Adelie418.035.73550.0202.0
\n", "
" ], "text/plain": [ "property species penguin number bill_depth_mm bill_length_mm body_mass_g \\\n", "0 Adelie 0 18.5 36.8 3500.0 \n", "1 Adelie 1 16.9 37.0 3000.0 \n", "2 Adelie 2 19.5 42.0 4050.0 \n", "3 Adelie 3 18.3 42.7 4075.0 \n", "4 Adelie 4 18.0 35.7 3550.0 \n", "\n", "property flipper_length_mm \n", "0 193.0 \n", "1 185.0 \n", "2 200.0 \n", "3 196.0 \n", "4 202.0 " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.reset_index()\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we do not need the column index to be named." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
speciespenguin numberbill_depth_mmbill_length_mmbody_mass_gflipper_length_mm
0Adelie018.536.83500.0193.0
1Adelie116.937.03000.0185.0
2Adelie219.542.04050.0200.0
3Adelie318.342.74075.0196.0
4Adelie418.035.73550.0202.0
\n", "
" ], "text/plain": [ " species penguin number bill_depth_mm bill_length_mm body_mass_g \\\n", "0 Adelie 0 18.5 36.8 3500.0 \n", "1 Adelie 1 16.9 37.0 3000.0 \n", "2 Adelie 2 19.5 42.0 4050.0 \n", "3 Adelie 3 18.3 42.7 4075.0 \n", "4 Adelie 4 18.0 35.7 3550.0 \n", "\n", " flipper_length_mm \n", "0 193.0 \n", "1 185.0 \n", "2 200.0 \n", "3 196.0 \n", "4 202.0 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.columns.name = None\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Beautiful! A tidy data frame! (Note that we can delete the `'penguin number'` column if we like because it is irrelevant. In most situations, I would delete it, but we will use it for illustrative purposes later in this lesson.)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Reshaping by unstacking\n", "\n", "Sometimes, our data set is tidy, contains all of the information we need, but is not in a convenient format. As an example, I will create a tidy data frame for the penguin data where each row is a single measurement of a single feature of a penguin. This is what we had before when we melted the data frame too soon, but if we melt the data frame now, specifying `'penguin number'` and `'species'` as ID variables, we get a tidy data frame that still has all of the information in the data set." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
penguin numberspeciesvariablevalue
00Adeliebill_depth_mm18.5
11Adeliebill_depth_mm16.9
22Adeliebill_depth_mm19.5
33Adeliebill_depth_mm18.3
44Adeliebill_depth_mm18.0
\n", "
" ], "text/plain": [ " penguin number species variable value\n", "0 0 Adelie bill_depth_mm 18.5\n", "1 1 Adelie bill_depth_mm 16.9\n", "2 2 Adelie bill_depth_mm 19.5\n", "3 3 Adelie bill_depth_mm 18.3\n", "4 4 Adelie bill_depth_mm 18.0" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.melt(id_vars=[\"penguin number\", \"species\"])\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This format is useful, but working with it can be more painful than in the previous format where each row corresponded to a measurement of a given _penguin_ as opposed to one measurement of one property of a penguin. The present data frame is in a sense too tall. We would like to widen it, or **unstack** it.\n", "\n", "To do this unstacking operation, we need to do two steps:\n", "\n", "1. Set the index of the data frame to be a multiindex based on all columns that are necessary to have a unique index for each row. In this case, that would be `'species'` and `'penguin number'`. Additionally, use the column whose entries you want to become column names upon unstacking as part of the multiindex. In this case, this is `'variable'`.\n", "2. Perform an unstacking operation with the level being the level of the multiindex you want to become the column names (in our case `'variable'`).\n", "\n", "Let's do it!" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
value
variablebill_depth_mmbill_length_mmbody_mass_gflipper_length_mm
speciespenguin number
Adelie018.536.83500.0193.0
116.937.03000.0185.0
219.542.04050.0200.0
318.342.74075.0196.0
418.035.73550.0202.0
\n", "
" ], "text/plain": [ " value \\\n", "variable bill_depth_mm bill_length_mm body_mass_g \n", "species penguin number \n", "Adelie 0 18.5 36.8 3500.0 \n", " 1 16.9 37.0 3000.0 \n", " 2 19.5 42.0 4050.0 \n", " 3 18.3 42.7 4075.0 \n", " 4 18.0 35.7 3550.0 \n", "\n", " \n", "variable flipper_length_mm \n", "species penguin number \n", "Adelie 0 193.0 \n", " 1 185.0 \n", " 2 200.0 \n", " 3 196.0 \n", " 4 202.0 " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Set index for necessary unique identifiers and column with desired column names\n", "df = df.set_index([\"species\", \"penguin number\", \"variable\"])\n", "\n", "# Unstack\n", "df = df.unstack(level=\"variable\")\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is close to the shape we want. We have multiindexes for both the rows and columns. To flatten the multiindexed column names, we could use `df.columns.to_flat_index()`, but this converts the multiindex to a single index comprised of tuples. So, the column names would be something like `('value', 'bill_depth_mm')`. Instead, we just want the inner level of the multiindex, which has a name `'variable'`. We can set the columns by getting the values of the indices at this level." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
variablebill_depth_mmbill_length_mmbody_mass_gflipper_length_mm
speciespenguin number
Adelie018.536.83500.0193.0
116.937.03000.0185.0
219.542.04050.0200.0
318.342.74075.0196.0
418.035.73550.0202.0
\n", "
" ], "text/plain": [ "variable bill_depth_mm bill_length_mm body_mass_g \\\n", "species penguin number \n", "Adelie 0 18.5 36.8 3500.0 \n", " 1 16.9 37.0 3000.0 \n", " 2 19.5 42.0 4050.0 \n", " 3 18.3 42.7 4075.0 \n", " 4 18.0 35.7 3550.0 \n", "\n", "variable flipper_length_mm \n", "species penguin number \n", "Adelie 0 193.0 \n", " 1 185.0 \n", " 2 200.0 \n", " 3 196.0 \n", " 4 202.0 " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.columns = df.columns.get_level_values(level=\"variable\")\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now all we are left to do is reset the index to bring the species and penguin number entries from indexes to columns in the data frame." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
variablespeciespenguin numberbill_depth_mmbill_length_mmbody_mass_gflipper_length_mm
0Adelie018.536.83500.0193.0
1Adelie116.937.03000.0185.0
2Adelie219.542.04050.0200.0
3Adelie318.342.74075.0196.0
4Adelie418.035.73550.0202.0
\n", "
" ], "text/plain": [ "variable species penguin number bill_depth_mm bill_length_mm body_mass_g \\\n", "0 Adelie 0 18.5 36.8 3500.0 \n", "1 Adelie 1 16.9 37.0 3000.0 \n", "2 Adelie 2 19.5 42.0 4050.0 \n", "3 Adelie 3 18.3 42.7 4075.0 \n", "4 Adelie 4 18.0 35.7 3550.0 \n", "\n", "variable flipper_length_mm \n", "0 193.0 \n", "1 185.0 \n", "2 200.0 \n", "3 196.0 \n", "4 202.0 " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.reset_index()\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### A couple of plots for fun\n", "\n", "Now that we've done all this work and our data set is tidy, let's make a plot for fun. First, we'll plot the ECDFs of the bill lengths." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function embed_document(root) {\n", " const docs_json = {\"3f3defcc-f124-42a8-a706-aa8fc6c1fd1f\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1012\"}],\"center\":[{\"id\":\"1015\"},{\"id\":\"1019\"}],\"frame_height\":275,\"frame_width\":400,\"left\":[{\"id\":\"1016\"}],\"renderers\":[{\"id\":\"1039\"},{\"id\":\"1046\"},{\"id\":\"1053\"}],\"right\":[{\"id\":\"1055\"}],\"title\":{\"id\":\"1059\"},\"toolbar\":{\"id\":\"1027\"},\"toolbar_location\":\"above\",\"x_range\":{\"id\":\"1004\"},\"x_scale\":{\"id\":\"1008\"},\"y_range\":{\"id\":\"1006\"},\"y_scale\":{\"id\":\"1010\"}},\"id\":\"1003\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1021\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1025\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1020\",\"type\":\"PanTool\"},{\"attributes\":{\"label\":{\"value\":\"Chinstrap\"},\"renderers\":[{\"id\":\"1046\"}]},\"id\":\"1057\",\"type\":\"LegendItem\"},{\"attributes\":{\"axis_label\":\"ECDF\",\"coordinates\":null,\"formatter\":{\"id\":\"1062\"},\"group\":null,\"major_label_policy\":{\"id\":\"1063\"},\"ticker\":{\"id\":\"1017\"}},\"id\":\"1016\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1013\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis_label\":\"bill length (mm)\",\"coordinates\":null,\"formatter\":{\"id\":\"1065\"},\"group\":null,\"major_label_policy\":{\"id\":\"1066\"},\"ticker\":{\"id\":\"1013\"}},\"id\":\"1012\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1023\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1069\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data\":{\"__ECDF\":{\"__ndarray__\":\"S0tLS0tL4z9aWlpaWlraP2lpaWlpaeE/tbS0tLS05D8tLS0tLS3lP/Hw8PDw8Og/AAAAAAAA6D+Ih4eHh4fnP+Lh4eHh4dE/Hh4eHh4e5j9LS0tLS0vbPzw8PDw8POQ/PDw8PDw83D88PDw8PDzsP7W0tLS0tNQ/aWlpaWlp6T+XlpaWlpamP1paWlpaWso/eHh4eHh46D88PDw8PDzMP+Lh4eHh4ek/Hh4eHh4ejj8PDw8PDw/vP9PS0tLS0uo/LS0tLS0t7T+XlpaWlpbmP9PS0tLS0rI/xMPDw8PD6z9aWlpaWlrqP5eWlpaWlu4/eHh4eHh42D8AAAAAAADgP4iHh4eHh+8/l5aWlpaW1j/T0tLS0tLSPw8PDw8PD+c/pqWlpaWl7T8tLS0tLS3dP7W0tLS0tMQ/l5aWlpaWxj/Ew8PDw8PTP9PS0tLS0sI/8fDw8PDw4D8eHh4eHh7OP+Lh4eHh4eE/8fDw8PDw0D+mpaWlpaXlPw8PDw8PD98/WlpaWlpauj+XlpaWlpa2Px4eHh4eHr4/AAAAAAAA0D9aWlpaWlriP2lpaWlpadk/8fDw8PDwwD+Ih4eHh4fXPx4eHh4eHq4/Hh4eHh4enj+1tLS0tLTsPx4eHh4eHu4/Hh4eHh4e3j9LS0tLS0vrP9PS0tLS0uI/xMPDw8PD4z94eHh4eHjgPwAAAAAAAPA/eHh4eHh4yD+mpaWlpaXVPw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"__label\":[\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\"],\"bill_depth_mm\":{\"__ndarray__\":\"zczMzMxMMECamZmZmZkvQGZmZmZmZixAZmZmZmZmL0AzMzMzMzMsQAAAAAAAAC5AZmZmZmZmL0BmZmZmZmYuQAAAAAAAAC5AMzMzMzMzMEAAAAAAAAAuQAAAAAAAADBAAAAAAAAAK0BmZmZmZmYvQM3MzMzMzCtAzczMzMzML0BmZmZmZmYrQJqZmZmZmSpAMzMzMzMzMECamZmZmZkvQJqZmZmZmS5AZmZmZmZmK0CamZmZmZkvQAAAAAAAAC5AAAAAAACAMECamZmZmRkwQDMzMzMzMypAzczMzMzML0BmZmZmZmYuQDMzMzMzMy9AzczMzMzMLUCamZmZmRkwQAAAAAAAADBAMzMzMzMzLkAAAAAAAAAtQAAAAAAAAC1AAAAAAAAAMUAAAAAAAAAtQGZmZmZmZi1AmpmZmZmZLEDNzMzMzMwrQM3MzMzMTDFAAAAAAAAAL0CamZmZmZkrQDMzMzMzMy5AZmZmZmZmK0AzMzMzMzMuQGZmZmZmZixAzczMzMzMKkAAAAAAAAAtQGZmZmZmZi5AmpmZmZmZLUCamZmZmZksQAAAAAAAAC1AMzMzMzMzK0BmZmZmZmYqQGZmZmZmZixAZmZmZmZmK0DNzMzMzEwxQJqZmZmZGTFAzczMzMzMLECamZmZmZksQDMzMzMzMy9AMzMzMzMzLUCamZmZmZksQAAAAAAAADFAZmZmZmZmL0AzMzMzMzMtQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[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oGpAAAAAAACAakAAAAAAAEBqQAAAAAAAIGpAAAAAAAAAakAAAAAAAGBqQAAAAAAAIGpAAAAAAACgakAAAAAAAIBsQAAAAAAAgGxAAAAAAAAga0AAAAAAAEBrQAAAAAAAoGtAAAAAAACgakAAAAAAAOBqQAAAAAAAgGxAAAAAAAAga0AAAAAAAEBqQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"index\":[136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\"]},\"selected\":{\"id\":\"1072\"},\"selection_policy\":{\"id\":\"1071\"}},\"id\":\"1048\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1024\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1070\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1062\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"source\":{\"id\":\"1041\"}},\"id\":\"1047\",\"type\":\"CDSView\"},{\"attributes\":{\"tools\":[{\"id\":\"1020\"},{\"id\":\"1021\"},{\"id\":\"1022\"},{\"id\":\"1023\"},{\"id\":\"1024\"},{\"id\":\"1025\"}]},\"id\":\"1027\",\"type\":\"Toolbar\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b3\"},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1036\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1063\",\"type\":\"AllLabels\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1048\"},\"glyph\":{\"id\":\"1050\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1052\"},\"nonselection_glyph\":{\"id\":\"1051\"},\"view\":{\"id\":\"1054\"}},\"id\":\"1053\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis\":{\"id\":\"1012\"},\"coordinates\":null,\"group\":null,\"ticker\":null},\"id\":\"1015\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1065\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1066\",\"type\":\"AllLabels\"},{\"attributes\":{\"fill_color\":{\"value\":\"#ff7e0e\"},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1043\",\"type\":\"Circle\"},{\"attributes\":{\"overlay\":{\"id\":\"1026\"}},\"id\":\"1022\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1004\",\"type\":\"DataRange1d\"},{\"attributes\":{\"click_policy\":\"hide\",\"coordinates\":null,\"group\":null,\"items\":[{\"id\":\"1056\"},{\"id\":\"1057\"},{\"id\":\"1058\"}],\"location\":\"center\"},\"id\":\"1055\",\"type\":\"Legend\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b3\"},\"hatch_alpha\":{\"value\":0.1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1037\",\"type\":\"Circle\"},{\"attributes\":{\"label\":{\"value\":\"Adelie\"},\"renderers\":[{\"id\":\"1039\"}]},\"id\":\"1056\",\"type\":\"LegendItem\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1041\"},\"glyph\":{\"id\":\"1043\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1045\"},\"nonselection_glyph\":{\"id\":\"1044\"},\"view\":{\"id\":\"1047\"}},\"id\":\"1046\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1067\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1071\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#ff7e0e\"},\"hatch_alpha\":{\"value\":0.2},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1045\",\"type\":\"Circle\"},{\"attributes\":{\"data\":{\"__ECDF\":{\"__ndarray__\":\"pqWlpaWl1T+XlpaWlpbWPzw8PDw8POw/LS0tLS0t7T8eHh4eHh6+Px4eHh4eHuY/8fDw8PDw6D/Ew8PDw8PTP5eWlpaWlqY/iIeHh4eH5z/x8PDw8PDAP9PS0tLS0rI/eHh4eHh46D9paWlpaWnZPzw8PDw8PNw/4uHh4eHh6T+1tLS0tLTsP3h4eHh4eMg/LS0tLS0t5T9aWlpaWlrKP+Lh4eHh4eE/AAAAAAAA4D94eHh4eHjgP2lpaWlpaeE/xMPDw8PD6z8PDw8PDw/fP7W0tLS0tOQ/WlpaWlpa4j9LS0tLS0vjP9PS0tLS0sI/Hh4eHh4ezj8AAAAAAADwP1paWlpaWuo/Hh4eHh4e3j/T0tLS0tLqPx4eHh4eHu4/WlpaWlpa2j8PDw8PDw/nP7W0tLS0tNQ/Hh4eHh4ejj+XlpaWlpa2P4iHh4eHh9c/4uHh4eHh0T9paWlpaWnpP5eWlpaWlu4/Dw8PDw8P7z8AAAAAAADQP/Hw8PDw8OA/Hh4eHh4enj+mpaWlpaXlP7W0tLS0tMQ/l5aWlpaWxj9LS0tLS0vbP9PS0tLS0tI/LS0tLS0t3T94eHh4eHjYPzw8PDw8PMw/xMPDw8PD4z88PDw8PDzkPx4eHh4eHq4/8fDw8PDw0D/T0tLS0tLiP6alpaWlpe0/S0tLS0tL6z+XlpaWlpbmPwAAAAAAAOg/iIeHh4eH7z9aWlpaWlq6Pw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"__label\":[\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\"],\"bill_depth_mm\":{\"__ndarray__\":\"AAAAAACAMkBmZmZmZuYwQAAAAAAAgDNAzczMzMxMMkAAAAAAAAAyQJqZmZmZGTNAZmZmZmZmMkBmZmZmZmYyQJqZmZmZGTJAAAAAAAAAMkBmZmZmZuYwQDMzMzMzMzFAAAAAAAAAM0DNzMzMzMwxQAAAAAAAgDJAmpmZmZkZM0AzMzMzMzM0QDMzMzMzMzFAzczMzMzMMkDNzMzMzEwxQAAAAAAAADFAmpmZmZkZMkCamZmZmRkxQJqZmZmZmTJAzczMzMxMMkDNzMzMzMwzQM3MzMzMzDFAAAAAAACAMEDNzMzMzMwxQJqZmZmZmTBAAAAAAACAM0AAAAAAAIA1QAAAAAAAADNAmpmZmZkZM0AzMzMzMzMyQAAAAAAAADNAzczMzMzMMEAAAAAAAAAxQM3MzMzMTDNAAAAAAAAAM0BmZmZmZuYxQAAAAAAAgDBAmpmZmZmZMEDNzMzMzMwwQAAAAAAAgDJAAAAAAAAAMkAAAAAAAAAxQM3MzMzMTDFAmpmZmZkZMUAzMzMzM7M0QJqZmZmZGTFAZmZmZmbmMUAAAAAAAIA0QAAAAAAAADJAZmZmZmbmMkCamZmZmRkyQJqZmZmZGTBAzczMzMzMMkAzMzMzM7MyQJqZmZmZGTJAmpmZmZkZMUCamZmZmZkxQAAAAAAAgDJAmpmZmZmZMkBmZmZmZuYyQGZmZmZm5jFAZmZmZmbmMkDNzMzMzMwvQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"bill_length_mm\":{\"__ndarray__\":\"ZmZmZmZmQkAAAAAAAIBCQAAAAAAAAEVAmpmZmZlZRUCamZmZmdlBQGZmZmZm5kNAZmZmZmZmREDNzMzMzExCQM3MzMzMDEFAZmZmZmYmRECamZmZmdlBQM3MzMzMTEFAzczMzMxMREBmZmZmZqZCQAAAAAAAwEJAzczMzMyMREAAAAAAAABFQJqZmZmZGUJAzczMzMzMQ0CamZmZmRlCQM3MzMzMDENAZmZmZmbmQkBmZmZmZuZCQDMzMzMz80JAAAAAAADARECamZmZmdlCQAAAAAAAwENAzczMzMwMQ0AzMzMzM3NDQDMzMzMz80FAZmZmZmYmQkAAAAAAAABHQM3MzMzMjERAzczMzMzMQkDNzMzMzIxEQJqZmZmZmUVAZmZmZmamQkCamZmZmRlEQJqZmZmZWUJAAAAAAADAQEAAAAAAAIBBQAAAAAAAgEJAAAAAAABAQkAzMzMzM3NEQJqZmZmZmUVAzczMzMwMRkAzMzMzMzNCQGZmZmZm5kJAAAAAAAAAQUDNzMzMzMxDQAAAAAAAAEJAAAAAAAAAQkBmZmZmZqZCQAAAAAAAQEJAAAAAAADAQkCamZmZmZlCQJqZmZmZGUJAMzMzMzNzQ0AAAAAAAIBDQAAAAAAAQEFAMzMzMzMzQkDNzMzMzAxDQGZmZmZmZkVAzczMzMyMREDNzMzMzAxEQAAAAAAAQERAZmZmZmbmRkCamZmZmZlBQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"body_mass_g\":{\"__ndarray__\":\"AAAAAABYq0AAAAAAAHCnQAAAAAAApK9AAAAAAADWr0AAAAAAALyrQAAAAAAAKrJAAAAAAAB4rkAAAAAAACarQAAAAAAAJqtAAAAAAABkqUAAAAAAAJyoQAAAAAAAAKlAAAAAAABAr0AAAAAAACyqQAAAAAAAe7FAAAAAAAAEsEAAAAAAAJqwQAAAAAAAnKhAAAAAAAD4sUAAAAAAAMipQAAAAAAAzqhAAAAAAABMrUAAA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gGZAAAAAAAAgZ0AAAAAAAOBnQAAAAAAAYGdAAAAAAADAZ0AAAAAAAOBoQAAAAAAAwGZAAAAAAABgZkAAAAAAAEBmQAAAAAAAYGdAAAAAAADAZ0AAAAAAACBnQAAAAAAAYGdAAAAAAAAAZ0AAAAAAAGBnQAAAAAAAYGhAAAAAAACgZ0AAAAAAAIBnQAAAAAAAYGdAAAAAAACgaEAAAAAAAEBnQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\"]},\"selected\":{\"id\":\"1068\"},\"selection_policy\":{\"id\":\"1067\"}},\"id\":\"1034\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1072\",\"type\":\"Selection\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ff7e0e\"},\"hatch_alpha\":{\"value\":0.1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1044\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1068\",\"type\":\"Selection\"},{\"attributes\":{\"source\":{\"id\":\"1034\"}},\"id\":\"1040\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1006\",\"type\":\"DataRange1d\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1034\"},\"glyph\":{\"id\":\"1036\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1038\"},\"nonselection_glyph\":{\"id\":\"1037\"},\"view\":{\"id\":\"1040\"}},\"id\":\"1039\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"label\":{\"value\":\"Gentoo\"},\"renderers\":[{\"id\":\"1053\"}]},\"id\":\"1058\",\"type\":\"LegendItem\"},{\"attributes\":{\"bottom_units\":\"screen\",\"coordinates\":null,\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"group\":null,\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1026\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"coordinates\":null,\"group\":null},\"id\":\"1059\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1008\",\"type\":\"LinearScale\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#2ba02b\"},\"hatch_alpha\":{\"value\":0.2},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#2ba02b\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1052\",\"type\":\"Circle\"},{\"attributes\":{\"fill_color\":{\"value\":\"#2ba02b\"},\"line_color\":{\"value\":\"#2ba02b\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1050\",\"type\":\"Circle\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2ba02b\"},\"hatch_alpha\":{\"value\":0.1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2ba02b\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1051\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1010\",\"type\":\"LinearScale\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#1f77b3\"},\"hatch_alpha\":{\"value\":0.2},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1038\",\"type\":\"Circle\"},{\"attributes\":{\"data\":{\"__ECDF\":{\"__ndarray__\":\"aWlpaWlp2T+XlpaWlpamPx4eHh4eHo4/Hh4eHh4e7j/x8PDw8PDAP3h4eHh4eOA/S0tLS0tL2z8eHh4eHh7ePx4eHh4eHuY/S0tLS0tL6z/Ew8PDw8PrPzw8PDw8POw/tbS0tLS0xD+XlpaWlpbGP5eWlpaWltY/eHh4eHh4yD94eHh4eHjoPw8PDw8PD98/09LS0tLS4j/x8PDw8PDoPy0tLS0tLeU/Hh4eHh4erj/T0tLS0tLqP8TDw8PDw9M/l5aWlpaW7j9paWlpaWnhPwAAAAAAAPA/pqWlpaWl5T+1tLS0tLTsP5eWlpaWluY/AAAAAAAA0D8eHh4eHh6ePw8PDw8PD+c/tbS0tLS01D88PDw8PDzcP1paWlpaWro/LS0tLS0t3T/T0tLS0tLSPzw8PDw8POQ/WlpaWlpa4j9paWlpaWnpPy0tLS0tLe0/iIeHh4eH1z8eHh4eHh6+P8TDw8PDw+M/pqWlpaWl1T9aWlpaWlrqP/Hw8PDw8NA/WlpaWlpayj/T0tLS0tKyP6alpaWlpe0/WlpaWlpa2j94eHh4eHjYP+Lh4eHh4dE/S0tLS0tL4z+XlpaWlpa2P/Hw8PDw8OA/4uHh4eHh4T8PDw8PDw/vPwAAAAAAAOA/iIeHh4eH7z/T0tLS0tLCP4iHh4eHh+c/AAAAAAAA6D/i4eHh4eHpP7W0tLS0tOQ/Hh4eHh4ezj88PDw8PDzMPw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"__label\":[\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\"],\"bill_depth_mm\":{\"__ndarray__\":\"zczMzMxMMkAzMzMzM7MwQJqZmZmZmTBAAAAAAAAANEAzMzMzM7MyQDMzMzMzMzJAAAAAAACAMUAzMzMzMzMyQAAAAAAAADNAAAAAAACAM0CamZmZmRkyQDMzMzMzszRAZmZmZmZmM0DNzMzMzEwxQJqZmZmZmTBAAAAAAAAAMUAzMzMzMzMzQGZmZmZm5jNAzczMzMzMMkAzMzMzMzMyQGZmZmZmZjNAzczMzMxMMUDNzMzMzEw0QM3MzMzMzDFAZmZmZmbmM0DNzMzMzEwxQM3MzMzMzDFAMzMzMzOzM0AAAAAAAAAzQAAAAAAAgDJAAAAAAACAMUDNzMzMzEwxQJqZmZmZGTNAZmZmZmbmMUCamZmZmZkzQM3MzMzMzDFAAAAAAACAM0BmZmZmZuYxQJqZmZmZmTNAZmZmZmbmMUBmZmZmZuYzQM3MzMzMzDJAzczMzMxMMUCamZmZmZkwQAAAAAAAADRAAAAAAACAMEAzMzMzM7MyQM3MzMzMzDFAmpmZmZkZMUCamZmZmZkwQM3MzMzMzDNAZmZmZmZmMEDNzMzMzMwwQJqZmZmZmTJAMzMzMzOzMkCamZmZmRkyQJqZmZmZmTJAAAAAAACAM0DNzMzMzMw0QAAAAAAAADNAzczMzMzMM0AAAAAAAAAxQGZmZmZm5jFAzczMzMzMMkAAAAAAAAAzQGZmZmZmZjJAMzMzMzMzMkBmZmZmZuYyQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"bill_length_mm\":{\"__ndarray__\":\"zczMzMzMR0AAAAAAAEBFQDMzMzMzc0RAZmZmZmZmSkAzMzMzM7NGQM3MzMzMzEhAAAAAAABASECamZ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AAAADgaUAAAAAAAIBoQAAAAAAAgGhAAAAAAABgaUAAAAAAACBpQAAAAAAAAGlAAAAAAABAZkAAAAAAAGBoQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"index\":[68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\"]},\"selected\":{\"id\":\"1070\"},\"selection_policy\":{\"id\":\"1069\"}},\"id\":\"1041\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1017\",\"type\":\"BasicTicker\"},{\"attributes\":{\"source\":{\"id\":\"1048\"}},\"id\":\"1054\",\"type\":\"CDSView\"},{\"attributes\":{\"axis\":{\"id\":\"1016\"},\"coordinates\":null,\"dimension\":1,\"group\":null,\"ticker\":null},\"id\":\"1019\",\"type\":\"Grid\"}],\"root_ids\":[\"1003\"]},\"title\":\"Bokeh Application\",\"version\":\"2.4.3\"}};\n", " const render_items = [{\"docid\":\"3f3defcc-f124-42a8-a706-aa8fc6c1fd1f\",\"root_ids\":[\"1003\"],\"roots\":{\"1003\":\"db10addd-fa97-496d-9d3b-e2dd4bbf4425\"}}];\n", " root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n", " }\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " } else {\n", " let attempts = 0;\n", " const timer = setInterval(function(root) {\n", " if (root.Bokeh !== undefined) {\n", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1003" } }, "output_type": "display_data" } ], "source": [ "bokeh.io.show(\n", " iqplot.ecdf(\n", " data=df,\n", " cats='species',\n", " q='bill_length_mm',\n", " x_axis_label='bill length (mm)',\n", " frame_width=400,\n", " )\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also plot bill length versus flipper length to see if we can see a difference among the species." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function embed_document(root) {\n", " const docs_json = {\"2647b03c-76bb-4c14-ab26-4a64702e9ccd\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1158\"}],\"center\":[{\"id\":\"1161\"},{\"id\":\"1165\"}],\"frame_height\":300,\"frame_width\":300,\"left\":[{\"id\":\"1162\"}],\"renderers\":[{\"id\":\"1185\"},{\"id\":\"1192\"},{\"id\":\"1199\"}],\"right\":[{\"id\":\"1201\"}],\"title\":{\"id\":\"1220\"},\"toolbar\":{\"id\":\"1173\"},\"toolbar_location\":\"above\",\"x_range\":{\"id\":\"1150\"},\"x_scale\":{\"id\":\"1154\"},\"y_range\":{\"id\":\"1152\"},\"y_scale\":{\"id\":\"1156\"}},\"id\":\"1149\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1233\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1229\",\"type\":\"Selection\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#1f77b4\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1184\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1232\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"source\":{\"id\":\"1180\"}},\"id\":\"1186\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_color\":{\"value\":\"#ff7f0e\"},\"hatch_color\":{\"value\":\"#ff7f0e\"},\"line_color\":{\"value\":\"#ff7f0e\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1189\",\"type\":\"Circle\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1187\"},\"glyph\":{\"id\":\"1189\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1191\"},\"nonselection_glyph\":{\"id\":\"1190\"},\"view\":{\"id\":\"1193\"}},\"id\":\"1192\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1194\"},\"glyph\":{\"id\":\"1196\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1198\"},\"nonselection_glyph\":{\"id\":\"1197\"},\"view\":{\"id\":\"1200\"}},\"id\":\"1199\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data\":{\"bill_depth_mm\":{\"__ndarray__\":\"zczMzMxMMECamZmZmZkvQGZmZmZmZixAZmZmZmZmL0AzMzMzMzMsQAAAAAAAAC5AZmZmZmZmL0BmZmZmZmYuQAAAAAAAAC5AMzMzMzMzMEAAAAAAAAAuQAAAAAAAADBAAAAAAAAAK0BmZmZmZmYvQM3MzMzMzCtAzczMzMzML0BmZmZmZmYrQJqZmZmZmSpAMzMzMzMzMECamZmZmZkvQJqZmZmZmS5AZmZmZmZmK0CamZmZmZkvQAAAAAAAAC5AAAAAAACAMECamZmZmRkwQDMzMzMzMypAzczMzMzML0BmZmZmZmYuQDMzMzMzMy9AzczMzMzMLUCamZmZmRkwQAAAAAAAADBAMzMzMzMzLkAAAAAAAAAtQAAAAAAAAC1AAAAAAAAAMUAAAAAAAAAtQGZmZmZmZi1AmpmZmZmZLEDNzMzMzMwrQM3MzMzMTDFAAAAAAAAAL0CamZmZmZkrQDMzMzMzMy5AZmZmZmZmK0AzMzMzMzMuQGZmZmZmZixAzczMzMzMKkAAAAAAAAAtQGZmZmZmZi5AmpmZmZmZLUCamZmZmZksQAAAAAAAAC1AMzMzMzMzK0BmZmZmZmYqQGZmZmZmZixAZmZmZmZmK0DNzMzMzEwxQJqZmZmZGTFAzczMzMzMLECamZmZmZksQDMzMzMzMy9AMzMzMzMzLUCamZmZmZksQAAAAAAAADFAZmZmZmZmL0AzMzMzMzMtQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"bill_length_mm\":{\"__ndarray__\":\"MzMzMzMzSEBmZmZmZiZHQAAAAAAAwEdAmpmZmZlZSECamZmZmVlIQM3MzMzMzEhAZmZmZmamSECamZmZmZlIQAAAAAAAwEZAZmZmZmZmSEAzMzMzMzNHQM3MzMzMTEhAAAAAAABAR0BmZmZmZmZJQJqZmZmZ2UZAAAAAAAAASUCamZmZmVlFQDMzMzMzc0ZAAAAAAADASECamZmZmZlGQAAAAAAAAElAMzMzMzNzREAzMzMzM7NKQM3MzMzMDElAzczMzMyMSUAAAAAAAIBIQDMzMzMzc0VAAAAAAABASUAAAAAAAABJQAAAAAAAQEpAmpmZmZkZR0BmZmZmZmZHQM3MzMzMjEtAzczMzMwMR0AAAAAAAMBGQM3MzMzMjEhAzczMzMwMSkAAAAAAAEBHQAAAAAAAQEZAAAAAAABARkAAAAAAAMBGQDMzMzMzM0ZAmpmZmZmZR0CamZmZmZlGQM3MzMzMDEhAZmZmZmamRkCamZmZmVlIQM3MzMzMTEdAZmZmZmamRUCamZmZmZlFQAAAAAAAwEVAmpmZmZmZRkCamZmZmRlIQJqZmZmZGUdAAAAAAAAARkDNzMzMzAxHQGZmZmZmZkVAzczMzMxMRUBmZmZmZmZJQJqZmZmZGUpAAAAAAABAR0CamZmZmRlJQJqZmZmZGUhAMzMzMzMzSEBmZmZmZmZHQDMzMzMz80tAAAAAAABARkBmZmZmZuZGQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"body_mass_g\":{\"__ndarray__\":\"AAAAAAAYtUAAAAAAALqzQAAAAAAA+LFAAAAAAADmtEAAAAAAAGKxQAAAAAAAjrJAAAAAAADatkAAAAAAAJy4QAAAAAAAiLNAAAAAAABwt0AAAAAAAFyyQAAAAAAAqLZAAAAAAADGsUAAAAAAAFC0QAAAAAAAMLFAAA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GtAAAAAAADgakAAAAAAAOBqQAAAAAAAIGpAAAAAAABAakAAAAAAAMBrQAAAAAAAQGpAAAAAAAAgakAAAAAAAABqQAAAAAAAoGpAAAAAAACAakAAAAAAAEBqQAAAAAAAIGpAAAAAAAAAakAAAAAAAGBqQAAAAAAAIGpAAAAAAACgakAAAAAAAIBsQAAAAAAAgGxAAAAAAAAga0AAAAAAAEBrQAAAAAAAoGtAAAAAAACgakAAAAAAAOBqQAAAAAAAgGxAAAAAAAAga0AAAAAAAEBqQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"index\":[136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\"]},\"selected\":{\"id\":\"1233\"},\"selection_policy\":{\"id\":\"1232\"}},\"id\":\"1194\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1180\"},\"glyph\":{\"id\":\"1182\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1184\"},\"nonselection_glyph\":{\"id\":\"1183\"},\"view\":{\"id\":\"1186\"}},\"id\":\"1185\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1170\",\"type\":\"ResetTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1183\",\"type\":\"Circle\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ff7f0e\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#ff7f0e\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ff7f0e\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1190\",\"type\":\"Circle\"},{\"attributes\":{\"axis\":{\"id\":\"1162\"},\"coordinates\":null,\"dimension\":1,\"group\":null,\"ticker\":null},\"id\":\"1165\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1223\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"axis\":{\"id\":\"1158\"},\"coordinates\":null,\"group\":null,\"ticker\":null},\"id\":\"1161\",\"type\":\"Grid\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#ff7f0e\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#ff7f0e\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#ff7f0e\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1191\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1159\",\"type\":\"BasicTicker\"},{\"attributes\":{\"coordinates\":null,\"group\":null},\"id\":\"1220\",\"type\":\"Title\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#2ca02c\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#2ca02c\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#2ca02c\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1198\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1169\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1163\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1154\",\"type\":\"LinearScale\"},{\"attributes\":{\"overlay\":{\"id\":\"1172\"}},\"id\":\"1168\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"coordinates\":null,\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"group\":null,\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1172\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data\":{\"bill_depth_mm\":{\"__ndarray__\":\"AAAA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qkAAAAAAAH6tQAAAAAAAnKhAAAAAAAA+p0AAAAAAAHiuQAAAAAAAvKtAAAAAAAAgrEAAAAAAAISsQAAAAAAAqKZAAAAAAABEpkAAAAAAAMKqQAAAAAAAmrBAAAAAAAD6qUAAAAAAAMywQAAAAAAAAKlAAAAAAAA2sEAAAAAAANSnQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"flipper_length_mm\":{\"__ndarray__\":\"AAAAAAAgaEAAAAAAACBnQAAAAAAAAGlAAAAAAACAaEAAAAAAAEBpQAAAAAAAAGdAAAAAAABgaEAAAAAAAABnQAAAAAAAIGhAAAAAAABgaEAAAAAAACBnQAAAAAAAoGdAAAAAAADgaEAAAAAAAOBnQAAAAAAA4GhAAAAAAACAZ0AAAAAAAMBnQAAAAAAAYGdAAAAAAADAZ0AAAAAAAGBnQAAAAAAAoGZAAAAAAAAgaEAAAAAAAEBnQAAAAAAAgGVAAAAAAABgaEAAAAAAAMBoQAAAAAAAgGdAAAAAAADAaEAAAAAAAKBmQAAAAAAAwGdAAAAAAADAZ0AAAAAAAEBoQAAAAAAAwGZAAAAAAABAaEAAAAAAAABoQAAAAAAAoGhAAAAAAAAAaEAAAAAAAABmQAAAAAAAIGhAAAAAAADAZ0AAAAAAAABoQAAAAAAAIGdAAAAAAACgZkAAAAAAAOBnQAAAAAAAAGhAAAAAAABAakAAAAAAAGBoQAAAAAAAgGZAAAAAAAAgZ0AAAAAAAOBnQAAAAAAAYGdAAAAAAADAZ0AAAAAAAOBoQAAAAAAAwGZAAAAAAABgZkAAAAAAAEBmQAAAAAAAYGdAAAAAAADAZ0AAAAAAACBnQAAAAAAAYGdAAAAAAAAAZ0AAAAAAAGBnQAAAAAAAYGhAAAAAAACgZ0AAAAAAAIBnQAAAAAAAYGdAAAAAAACgaEAAAAAAAEBnQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\"]},\"selected\":{\"id\":\"1229\"},\"selection_policy\":{\"id\":\"1228\"}},\"id\":\"1180\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis_label\":\"flipper length (mm)\",\"coordinates\":null,\"formatter\":{\"id\":\"1223\"},\"group\":null,\"major_label_policy\":{\"id\":\"1224\"},\"ticker\":{\"id\":\"1163\"}},\"id\":\"1162\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1230\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"axis_label\":\"bill length (mm)\",\"coordinates\":null,\"formatter\":{\"id\":\"1226\"},\"group\":null,\"major_label_policy\":{\"id\":\"1227\"},\"ticker\":{\"id\":\"1159\"}},\"id\":\"1158\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"1194\"}},\"id\":\"1200\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1224\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"1156\",\"type\":\"LinearScale\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"hatch_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1182\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1231\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1152\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1226\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"label\":{\"value\":\"Adelie\"},\"renderers\":[{\"id\":\"1185\"}]},\"id\":\"1202\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1166\",\"type\":\"PanTool\"},{\"attributes\":{\"source\":{\"id\":\"1187\"}},\"id\":\"1193\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2ca02c\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#2ca02c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2ca02c\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1197\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1171\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1150\",\"type\":\"DataRange1d\"},{\"attributes\":{\"click_policy\":\"hide\",\"coordinates\":null,\"group\":null,\"items\":[{\"id\":\"1202\"},{\"id\":\"1203\"},{\"id\":\"1204\"}],\"location\":\"center\"},\"id\":\"1201\",\"type\":\"Legend\"},{\"attributes\":{},\"id\":\"1227\",\"type\":\"AllLabels\"},{\"attributes\":{\"label\":{\"value\":\"Gentoo\"},\"renderers\":[{\"id\":\"1199\"}]},\"id\":\"1204\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1167\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"tools\":[{\"id\":\"1166\"},{\"id\":\"1167\"},{\"id\":\"1168\"},{\"id\":\"1169\"},{\"id\":\"1170\"},{\"id\":\"1171\"}]},\"id\":\"1173\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1228\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data\":{\"bill_depth_mm\":{\"__ndarray__\":\"zczMzMxMMkAzMzMzM7MwQJqZmZmZmTBAAAAAAAAANEAzMzMzM7MyQDMzMzMzMzJAAAAAAACAMUAzMzMzMzMyQAAAAAAAADNAAAAAAACAM0CamZmZmRkyQDMzMzMzszRAZmZmZmZmM0DNzMzMzEwxQJqZmZmZmTBAAAAAAAAAMUAzMzMzMzMzQGZmZmZm5jNAzczMzMzMMkAzMzMzMzMyQGZmZmZmZjNAzczMzMxMMUDNzMzMzEw0QM3MzMzMzDFAZmZmZmbmM0DNzMzMzEwxQM3MzMzMzDFAMzMzMzOzM0AAAAAAAAAzQAAAAAAAgDJAAAAAAACAMUDNzMzMzEwxQJqZmZmZGTNAZmZmZmbmMUCamZmZmZkzQM3MzMzMzDFAAAAAAACAM0BmZmZmZuYxQJqZmZmZmTNAZmZmZmbmMUBmZmZmZuYzQM3MzMzMzDJAzczMzMxMMUCamZmZmZkwQAAAAAAAADRAAAAAAACAMEAzMzMzM7MyQM3MzMzMzDFAmpmZmZkZMUCamZmZmZkwQM3MzMzMzDNAZmZmZmZmMEDNzMzMzMwwQJqZmZmZmTJAMzMzMzOzMkCamZmZmRkyQJqZmZmZmTJAAAAAAACAM0DNzMzMzMw0QAAAAAAAADNAzczMzMzMM0AAAAAAAAAxQGZmZmZm5jFAzczMzMzMMkAAAAAAAAAzQGZmZmZmZjJAMzMzMzMzMkBmZmZmZuYyQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"bill_length_mm\":{\"__ndarray__\":\"zczMzMzMR0AAAAAAAEBFQDMzMzMzc0RAZmZmZmZmSkAzMzMzM7NGQM3MzMzMzEhAAAAAAABASECamZmZmZlIQGZmZmZmZklAMzMzMzPzSUAAAAAAAABKQAAAAAAAAEpAzczMzMzMRkCamZmZmdlGQDMzMzMzc0dAmpmZmZnZRkBmZmZmZqZJQGZmZmZmpkhAmpmZmZkZSUBmZmZmZqZJQM3MzMzMTElAAAAAAABARUCamZmZmdlJQM3MzMzMTEdAAAAAAADASkBmZmZmZuZIQAAAAAAAAE1AmpmZmZlZSUAAAAAAAABKQGZmZmZmZklAmpmZmZkZR0AzMzMzMzNFQDMzMzMzc0lAmpmZmZlZR0AAAAAAAIBIQJqZmZmZmUZAAAAAAACASEAAAAAAAEBHQAAAAAAAQElAzczMzMwMSUBmZmZmZqZJQJqZmZmZGUpAAAAAAACAR0CamZmZmZlGQGZmZmZmJklAZmZmZmZmR0AAAAAAAMBJQDMzMzMzM0dAMzMzMzPzRkCamZmZmZlFQJqZmZmZWUpAzczMzMwMSEAAAAAAAMBHQDMzMzMzM0dAmpmZmZkZSUAAAAAAAMBFQJqZmZmZ2UhAAAAAAAAASUCamZmZmRlLQAAAAAAAwEhAZmZmZmbmS0AAAAAAAMBGQDMzMzMzc0lAAAAAAACASUAzMzMzM7NJQAAAAAAAQElAzczMzMwMR0AAAAAAAABHQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"body_mass_g\":{\"__ndarray__\":\"AAAAAAAUrkAAAAAAACyqQAAAAAAAAKlAAAAAAADGsUAAAAAAAIqrQAAAAAAAfq1AAAAAAACQqkAAAAAAADCxQAAA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AAAAwGhAAAAAAABAakAAAAAAAABoQAAAAAAAIGlAAAAAAADAZ0AAAAAAAMBoQAAAAAAAoGhAAAAAAAAgZ0AAAAAAAOBnQAAAAAAAoGhAAAAAAACgZ0AAAAAAAGBnQAAAAAAA4GdAAAAAAADAZ0AAAAAAAGBnQAAAAAAAoGhAAAAAAADgaEAAAAAAAOBoQAAAAAAAwGdAAAAAAADAaEAAAAAAAEBpQAAAAAAAYGhAAAAAAACAaEAAAAAAACBpQAAAAAAAAGlAAAAAAADgaUAAAAAAAIBoQAAAAAAAgGhAAAAAAABgaUAAAAAAACBpQAAAAAAAAGlAAAAAAABAZkAAAAAAAGBoQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"index\":[68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\"]},\"selected\":{\"id\":\"1231\"},\"selection_policy\":{\"id\":\"1230\"}},\"id\":\"1187\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"label\":{\"value\":\"Chinstrap\"},\"renderers\":[{\"id\":\"1192\"}]},\"id\":\"1203\",\"type\":\"LegendItem\"},{\"attributes\":{\"fill_color\":{\"value\":\"#2ca02c\"},\"hatch_color\":{\"value\":\"#2ca02c\"},\"line_color\":{\"value\":\"#2ca02c\"},\"x\":{\"field\":\"bill_length_mm\"},\"y\":{\"field\":\"flipper_length_mm\"}},\"id\":\"1196\",\"type\":\"Circle\"}],\"root_ids\":[\"1149\"]},\"title\":\"Bokeh Application\",\"version\":\"2.4.3\"}};\n", " const render_items = [{\"docid\":\"2647b03c-76bb-4c14-ab26-4a64702e9ccd\",\"root_ids\":[\"1149\"],\"roots\":{\"1149\":\"a0534c4a-e424-44e8-b316-e14b0900cab6\"}}];\n", " root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n", " }\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " } else {\n", " let attempts = 0;\n", " const timer = setInterval(function(root) {\n", " if (root.Bokeh !== undefined) {\n", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1149" } }, "output_type": "display_data" } ], "source": [ "# Create figure\n", "p = bokeh.plotting.figure(\n", " frame_width=300,\n", " frame_height=300,\n", " x_axis_label=\"bill length (mm)\",\n", " y_axis_label=\"flipper length (mm)\",\n", " toolbar_location=\"above\",\n", ")\n", "\n", "# Build legend as we populate glyphs\n", "legend_items = []\n", "for color, (species, g) in zip(bokeh.palettes.Category10_3, df.groupby(\"species\")):\n", " glyph = p.circle(source=g, x=\"bill_length_mm\", y=\"flipper_length_mm\", color=color)\n", " legend_items.append((species, [glyph]))\n", "\n", "# Place legend\n", "legend = bokeh.models.Legend(items=legend_items, location=\"center\")\n", "p.add_layout(legend, \"right\")\n", "p.legend.click_policy = \"hide\"\n", "\n", "bokeh.io.show(p)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## An important note about tidiness\n", "\n", "It is important to note that there is more than one way to make a data set tidy. In the example of the Palmer penguin data set, we saw two legitimate ways of making the data frame tidy. In our preferred version, each row corresponded to a measurement of a single _penguin_, which had several variables associated with it. In another version, each row corresponded to a single _feature_ of a penguin.\n", "\n", "To demonstrate that this latter version is workable, but more cumbersome, we can make the same plots as above. First, we'll melt it again." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
penguin numberspeciesvariablevalue
00Adeliebill_depth_mm18.5
11Adeliebill_depth_mm16.9
22Adeliebill_depth_mm19.5
33Adeliebill_depth_mm18.3
44Adeliebill_depth_mm18.0
\n", "
" ], "text/plain": [ " penguin number species variable value\n", "0 0 Adelie bill_depth_mm 18.5\n", "1 1 Adelie bill_depth_mm 16.9\n", "2 2 Adelie bill_depth_mm 19.5\n", "3 3 Adelie bill_depth_mm 18.3\n", "4 4 Adelie bill_depth_mm 18.0" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.melt(id_vars=[\"penguin number\", \"species\"])\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotting the ECDFs is not really a problem with this form of the data frame. We just need to use Boolean indexing to pull out the bill length rows." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function embed_document(root) {\n", " const docs_json = {\"31a89ea4-6146-459d-91db-13d391278761\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1319\"}],\"center\":[{\"id\":\"1322\"},{\"id\":\"1326\"}],\"frame_height\":275,\"frame_width\":400,\"left\":[{\"id\":\"1323\"}],\"renderers\":[{\"id\":\"1346\"},{\"id\":\"1353\"},{\"id\":\"1360\"}],\"right\":[{\"id\":\"1362\"}],\"title\":{\"id\":\"1396\"},\"toolbar\":{\"id\":\"1334\"},\"toolbar_location\":\"above\",\"x_range\":{\"id\":\"1311\"},\"x_scale\":{\"id\":\"1315\"},\"y_range\":{\"id\":\"1313\"},\"y_scale\":{\"id\":\"1317\"}},\"id\":\"1310\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#ff7e0e\"},\"hatch_alpha\":{\"value\":0.2},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1352\",\"type\":\"Circle\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b3\"},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1343\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1320\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1319\"},\"coordinates\":null,\"group\":null,\"ticker\":null},\"id\":\"1322\",\"type\":\"Grid\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1341\"},\"glyph\":{\"id\":\"1343\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1345\"},\"nonselection_glyph\":{\"id\":\"1344\"},\"view\":{\"id\":\"1347\"}},\"id\":\"1346\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom_units\":\"screen\",\"coordinates\":null,\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"group\":null,\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1333\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"click_policy\":\"hide\",\"coordinates\":null,\"group\":null,\"items\":[{\"id\":\"1363\"},{\"id\":\"1364\"},{\"id\":\"1365\"}],\"location\":\"center\"},\"id\":\"1362\",\"type\":\"Legend\"},{\"attributes\":{\"fill_color\":{\"value\":\"#2ba02b\"},\"line_color\":{\"value\":\"#2ba02b\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1357\",\"type\":\"Circle\"},{\"attributes\":{\"coordinates\":null,\"group\":null},\"id\":\"1396\",\"type\":\"Title\"},{\"attributes\":{\"label\":{\"value\":\"Adelie\"},\"renderers\":[{\"id\":\"1346\"}]},\"id\":\"1363\",\"type\":\"LegendItem\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#1f77b3\"},\"hatch_alpha\":{\"value\":0.2},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1345\",\"type\":\"Circle\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#2ba02b\"},\"hatch_alpha\":{\"value\":0.2},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#2ba02b\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1359\",\"type\":\"Circle\"},{\"attributes\":{\"data\":{\"__ECDF\":{\"__ndarray__\":\"pqWlpaWl1T+XlpaWlpbWPzw8PDw8POw/LS0tLS0t7T8eHh4eHh6+Px4eHh4eHuY/8fDw8PDw6D/Ew8PDw8PTP5eWlpaWlqY/iIeHh4eH5z/x8PDw8PDAP9PS0tLS0rI/eHh4eHh46D9paWlpaWnZPzw8PDw8PNw/4uHh4eHh6T+1tLS0tLTsP3h4eHh4eMg/LS0tLS0t5T9aWlpaWlrKP+Lh4eHh4eE/AAAAAAAA4D94eHh4eHjgP2lpaWlpaeE/xMPDw8PD6z8PDw8PDw/fP7W0tLS0tOQ/WlpaWlpa4j9LS0tLS0vjP9PS0tLS0sI/Hh4eHh4ezj8AAAAAAADwP1paWlpaWuo/Hh4eHh4e3j/T0tLS0tLqPx4eHh4eHu4/WlpaWlpa2j8PDw8PDw/nP7W0tLS0tNQ/Hh4eHh4ejj+XlpaWlpa2P4iHh4eHh9c/4uHh4eHh0T9paWlpaWnpP5eWlpaWlu4/Dw8PDw8P7z8AAAAAAADQP/Hw8PDw8OA/Hh4eHh4enj+mpaWlpaXlP7W0tLS0tMQ/l5aWlpaWxj9LS0tLS0vbP9PS0tLS0tI/LS0tLS0t3T94eHh4eHjYPzw8PDw8PMw/xMPDw8PD4z88PDw8PDzkPx4eHh4eHq4/8fDw8PDw0D/T0tLS0tLiP6alpaWlpe0/S0tLS0tL6z+XlpaWlpbmPwAAAAAAAOg/iIeHh4eH7z9aWlpaWlq6Pw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"__label\":[\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\"],\"index\":[204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\",\"Adelie\"],\"value\":{\"__ndarray__\":\"ZmZmZmZmQkAAAAAAAIBCQAAAAAAAAEVAmpmZmZlZRUCamZmZmdlBQGZmZmZm5kNAZmZmZmZmREDNzMzMzExCQM3MzMzMDEFAZmZmZmYmRECamZmZmdlBQM3MzMzMTEFAzczMzMxMREBmZmZmZqZCQAAAAAAAwEJAzczMzMyMREAAAAAAAABFQJqZmZmZGUJAzczMzMzMQ0CamZmZmRlCQM3MzMzMDENAZmZmZmbmQkBmZmZmZuZCQDMzMzMz80JAAAAAAADARECamZmZmdlCQAAAAAAAwENAzczMzMwMQ0AzMzMzM3NDQDMzMzMz80FAZmZmZmYmQkAAAAAAAABHQM3MzMzMjERAzczMzMzMQkDNzMzMzIxEQJqZmZmZmUVAZmZmZmamQkCamZmZmRlEQJqZmZmZWUJAAAAAAADAQEAAAAAAAIBBQAAAAAAAgEJAAAAAAABAQkAzMzMzM3NEQJqZmZmZmUVAzczMzMwMRkAzMzMzMzNCQGZmZmZm5kJAAAAAAAAAQUDNzMzMzMxDQAAAAAAAAEJAAAAAAAAAQkBmZmZmZqZCQAAAAAAAQEJAAAAAAADAQkCamZmZmZlCQJqZmZmZGUJAMzMzMzNzQ0AAAAAAAIBDQAAAAAAAQEFAMzMzMzMzQkDNzMzMzAxDQGZmZmZmZkVAzczMzMyMREDNzMzMzAxEQAAAAAAAQERAZmZmZmbmRkCamZmZmZlBQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"variable\":[\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\"]},\"selected\":{\"id\":\"1405\"},\"selection_policy\":{\"id\":\"1404\"}},\"id\":\"1341\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b3\"},\"hatch_alpha\":{\"value\":0.1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b3\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1344\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1404\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"source\":{\"id\":\"1355\"}},\"id\":\"1361\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1324\",\"type\":\"BasicTicker\"},{\"attributes\":{\"source\":{\"id\":\"1341\"}},\"id\":\"1347\",\"type\":\"CDSView\"},{\"attributes\":{\"label\":{\"value\":\"Gentoo\"},\"renderers\":[{\"id\":\"1360\"}]},\"id\":\"1365\",\"type\":\"LegendItem\"},{\"attributes\":{\"data\":{\"__ECDF\":{\"__ndarray__\":\"S0tLS0tL4z9aWlpaWlraP2lpaWlpaeE/tbS0tLS05D8tLS0tLS3lP/Hw8PDw8Og/AAAAAAAA6D+Ih4eHh4fnP+Lh4eHh4dE/Hh4eHh4e5j9LS0tLS0vbPzw8PDw8POQ/PDw8PDw83D88PDw8PDzsP7W0tLS0tNQ/aWlpaWlp6T+XlpaWlpamP1paWlpaWso/eHh4eHh46D88PDw8PDzMP+Lh4eHh4ek/Hh4eHh4ejj8PDw8PDw/vP9PS0tLS0uo/LS0tLS0t7T+XlpaWlpbmP9PS0tLS0rI/xMPDw8PD6z9aWlpaWlrqP5eWlpaWlu4/eHh4eHh42D8AAAAAAADgP4iHh4eHh+8/l5aWlpaW1j/T0tLS0tLSPw8PDw8PD+c/pqWlpaWl7T8tLS0tLS3dP7W0tLS0tMQ/l5aWlpaWxj/Ew8PDw8PTP9PS0tLS0sI/8fDw8PDw4D8eHh4eHh7OP+Lh4eHh4eE/8fDw8PDw0D+mpaWlpaXlPw8PDw8PD98/WlpaWlpauj+XlpaWlpa2Px4eHh4eHr4/AAAAAAAA0D9aWlpaWlriP2lpaWlpadk/8fDw8PDwwD+Ih4eHh4fXPx4eHh4eHq4/Hh4eHh4enj+1tLS0tLTsPx4eHh4eHu4/Hh4eHh4e3j9LS0tLS0vrP9PS0tLS0uI/xMPDw8PD4z94eHh4eHjgPwAAAAAAAPA/eHh4eHh4yD+mpaWlpaXVPw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"__label\":[\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\"],\"index\":[340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\",\"Gentoo\"],\"value\":{\"__ndarray__\":\"MzMzMzMzSEBmZmZmZiZHQAAAAAAAwEdAmpmZmZlZSECamZmZmVlIQM3MzMzMzEhAZmZmZmamSECamZmZmZlIQAAAAAAAwEZAZmZmZmZmSEAzMzMzMzNHQM3MzMzMTEhAAAAAAABAR0BmZmZmZmZJQJqZmZmZ2UZAAAAAAAAASUCamZmZmVlFQDMzMzMzc0ZAAAAAAADASECamZmZmZlGQAAAAAAAAElAMzMzMzNzREAzMzMzM7NKQM3MzMzMDElAzczMzMyMSUAAAAAAAIBIQDMzMzMzc0VAAAAAAABASUAAAAAAAABJQAAAAAAAQEpAmpmZmZkZR0BmZmZmZmZHQM3MzMzMjEtAzczMzMwMR0AAAAAAAMBGQM3MzMzMjEhAzczMzMwMSkAAAAAAAEBHQAAAAAAAQEZAAAAAAABARkAAAAAAAMBGQDMzMzMzM0ZAmpmZmZmZR0CamZmZmZlGQM3MzMzMDEhAZmZmZmamRkCamZmZmVlIQM3MzMzMTEdAZmZmZmamRUCamZmZmZlFQAAAAAAAwEVAmpmZmZmZRkCamZmZmRlIQJqZmZmZGUdAAAAAAAAARkDNzMzMzAxHQGZmZmZmZkVAzczMzMxMRUBmZmZmZmZJQJqZmZmZGUpAAAAAAABAR0CamZmZmRlJQJqZmZmZGUhAMzMzMzMzSEBmZmZmZmZHQDMzMzMz80tAAAAAAABARkBmZmZmZuZGQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"variable\":[\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\"]},\"selected\":{\"id\":\"1409\"},\"selection_policy\":{\"id\":\"1408\"}},\"id\":\"1355\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis_label\":\"ECDF\",\"coordinates\":null,\"formatter\":{\"id\":\"1399\"},\"group\":null,\"major_label_policy\":{\"id\":\"1400\"},\"ticker\":{\"id\":\"1324\"}},\"id\":\"1323\",\"type\":\"LinearAxis\"},{\"attributes\":{\"data\":{\"__ECDF\":{\"__ndarray__\":\"aWlpaWlp2T+XlpaWlpamPx4eHh4eHo4/Hh4eHh4e7j/x8PDw8PDAP3h4eHh4eOA/S0tLS0tL2z8eHh4eHh7ePx4eHh4eHuY/S0tLS0tL6z/Ew8PDw8PrPzw8PDw8POw/tbS0tLS0xD+XlpaWlpbGP5eWlpaWltY/eHh4eHh4yD94eHh4eHjoPw8PDw8PD98/09LS0tLS4j/x8PDw8PDoPy0tLS0tLeU/Hh4eHh4erj/T0tLS0tLqP8TDw8PDw9M/l5aWlpaW7j9paWlpaWnhPwAAAAAAAPA/pqWlpaWl5T+1tLS0tLTsP5eWlpaWluY/AAAAAAAA0D8eHh4eHh6ePw8PDw8PD+c/tbS0tLS01D88PDw8PDzcP1paWlpaWro/LS0tLS0t3T/T0tLS0tLSPzw8PDw8POQ/WlpaWlpa4j9paWlpaWnpPy0tLS0tLe0/iIeHh4eH1z8eHh4eHh6+P8TDw8PDw+M/pqWlpaWl1T9aWlpaWlrqP/Hw8PDw8NA/WlpaWlpayj/T0tLS0tKyP6alpaWlpe0/WlpaWlpa2j94eHh4eHjYP+Lh4eHh4dE/S0tLS0tL4z+XlpaWlpa2P/Hw8PDw8OA/4uHh4eHh4T8PDw8PDw/vPwAAAAAAAOA/iIeHh4eH7z/T0tLS0tLCP4iHh4eHh+c/AAAAAAAA6D/i4eHh4eHpP7W0tLS0tOQ/Hh4eHh4ezj88PDw8PDzMPw==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"__label\":[\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\"],\"index\":[272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339],\"penguin number\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67],\"species\":[\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\",\"Chinstrap\"],\"value\":{\"__ndarray__\":\"zczMzMzMR0AAAAAAAEBFQDMzMzMzc0RAZmZmZmZmSkAzMzMzM7NGQM3MzMzMzEhAAAAAAABASECamZmZmZlIQGZmZmZmZklAMzMzMzPzSUAAAAAAAABKQAAAAAAAAEpAzczMzMzMRkCamZmZmdlGQDMzMzMzc0dAmpmZmZnZRkBmZmZmZqZJQGZmZmZmpkhAmpmZmZkZSUBmZmZmZqZJQM3MzMzMTElAAAAAAABARUCamZmZmdlJQM3MzMzMTEdAAAAAAADASkBmZmZmZuZIQAAAAAAAAE1AmpmZmZlZSUAAAAAAAABKQGZmZmZmZklAmpmZmZkZR0AzMzMzMzNFQDMzMzMzc0lAmpmZmZlZR0AAAAAAAIBIQJqZmZmZmUZAAAAAAACASEAAAAAAAEBHQAAAAAAAQElAzczMzMwMSUBmZmZmZqZJQJqZmZmZGUpAAAAAAACAR0CamZmZmZlGQGZmZmZmJklAZmZmZmZmR0AAAAAAAMBJQDMzMzMzM0dAMzMzMzPzRkCamZmZmZlFQJqZmZmZWUpAzczMzMwMSEAAAAAAAMBHQDMzMzMzM0dAmpmZmZkZSUAAAAAAAMBFQJqZmZmZ2UhAAAAAAAAASUCamZmZmRlLQAAAAAAAwEhAZmZmZmbmS0AAAAAAAMBGQDMzMzMzc0lAAAAAAACASUAzMzMzM7NJQAAAAAAAQElAzczMzMwMR0AAAAAAAABHQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"variable\":[\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\",\"bill_length_mm\"]},\"selected\":{\"id\":\"1407\"},\"selection_policy\":{\"id\":\"1406\"}},\"id\":\"1348\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1408\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1405\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1409\",\"type\":\"Selection\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1355\"},\"glyph\":{\"id\":\"1357\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1359\"},\"nonselection_glyph\":{\"id\":\"1358\"},\"view\":{\"id\":\"1361\"}},\"id\":\"1360\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1332\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1327\",\"type\":\"PanTool\"},{\"attributes\":{\"axis\":{\"id\":\"1323\"},\"coordinates\":null,\"dimension\":1,\"group\":null,\"ticker\":null},\"id\":\"1326\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1330\",\"type\":\"SaveTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2ba02b\"},\"hatch_alpha\":{\"value\":0.1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2ba02b\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1358\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1331\",\"type\":\"ResetTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ff7e0e\"},\"hatch_alpha\":{\"value\":0.1},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1351\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1311\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1328\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1400\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"1315\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1317\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1403\",\"type\":\"AllLabels\"},{\"attributes\":{},\"id\":\"1313\",\"type\":\"DataRange1d\"},{\"attributes\":{\"label\":{\"value\":\"Chinstrap\"},\"renderers\":[{\"id\":\"1353\"}]},\"id\":\"1364\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1406\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"tools\":[{\"id\":\"1327\"},{\"id\":\"1328\"},{\"id\":\"1329\"},{\"id\":\"1330\"},{\"id\":\"1331\"},{\"id\":\"1332\"}]},\"id\":\"1334\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1407\",\"type\":\"Selection\"},{\"attributes\":{\"overlay\":{\"id\":\"1333\"}},\"id\":\"1329\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1399\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"fill_color\":{\"value\":\"#ff7e0e\"},\"line_color\":{\"value\":\"#ff7e0e\"},\"x\":{\"field\":\"value\"},\"y\":{\"field\":\"__ECDF\"}},\"id\":\"1350\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1402\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1348\"},\"glyph\":{\"id\":\"1350\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1352\"},\"nonselection_glyph\":{\"id\":\"1351\"},\"view\":{\"id\":\"1354\"}},\"id\":\"1353\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis_label\":\"bill length (mm)\",\"coordinates\":null,\"formatter\":{\"id\":\"1402\"},\"group\":null,\"major_label_policy\":{\"id\":\"1403\"},\"ticker\":{\"id\":\"1320\"}},\"id\":\"1319\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"1348\"}},\"id\":\"1354\",\"type\":\"CDSView\"}],\"root_ids\":[\"1310\"]},\"title\":\"Bokeh Application\",\"version\":\"2.4.3\"}};\n", " const render_items = [{\"docid\":\"31a89ea4-6146-459d-91db-13d391278761\",\"root_ids\":[\"1310\"],\"roots\":{\"1310\":\"827bdc96-00cb-4f6f-9d19-cbebc61665ee\"}}];\n", " root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n", " }\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " } else {\n", " let attempts = 0;\n", " const timer = setInterval(function(root) {\n", " if (root.Bokeh !== undefined) {\n", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1310" } }, "output_type": "display_data" } ], "source": [ "bokeh.io.show(\n", " iqplot.ecdf(\n", " data=df.loc[df[\"variable\"] == \"bill_length_mm\", :],\n", " q=\"value\",\n", " cats=\"species\",\n", " frame_width=400,\n", " x_axis_label=\"bill length (mm)\",\n", " )\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Making the scatter plot, however, is much more difficult and involves a lot of Boolean indexing by hand." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function embed_document(root) {\n", " const docs_json = {\"3c278beb-0c4b-4a08-a148-5229d0a681f7\":{\"defs\":[],\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1495\"}],\"center\":[{\"id\":\"1498\"},{\"id\":\"1502\"}],\"frame_height\":300,\"frame_width\":300,\"left\":[{\"id\":\"1499\"}],\"renderers\":[{\"id\":\"1521\"},{\"id\":\"1527\"},{\"id\":\"1533\"}],\"right\":[{\"id\":\"1535\"}],\"title\":{\"id\":\"1584\"},\"toolbar\":{\"id\":\"1510\"},\"toolbar_location\":\"above\",\"x_range\":{\"id\":\"1487\"},\"x_scale\":{\"id\":\"1491\"},\"y_range\":{\"id\":\"1489\"},\"y_scale\":{\"id\":\"1493\"}},\"id\":\"1486\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"source\":{\"id\":\"1517\"}},\"id\":\"1522\",\"type\":\"CDSView\"},{\"attributes\":{\"data\":{\"x\":{\"__ndarray__\":\"ZmZmZmZmQkAAAAAAAIBCQAAAAAAAAEVAmpmZmZlZRUCamZmZmdlBQGZmZmZm5kNAZmZmZmZmREDNzMzMzExCQM3MzMzMDEFAZmZmZmYmRECamZmZmdlBQM3MzMzMTEFAzczMzMxMREBmZmZmZqZCQAAAAAAAwEJAzczMzMyMREAAAAAAAABFQJqZmZmZGUJAzczMzMzMQ0CamZmZmRlCQM3MzMzMDENAZmZmZmbmQkBmZmZmZuZCQDMzMzMz80JAAAAAAADARECamZmZmdlCQAAAAAAAwENAzczMzMwMQ0AzMzMzM3NDQDMzMzMz80FAZmZmZmYmQkAAAAAAAABHQM3MzMzMjERAzczMzMzMQkDNzMzMzIxEQJqZmZmZmUVAZmZmZmamQkCamZmZmRlEQJqZmZmZWUJAAAAAAADAQEAAAAAAAIBBQAAAAAAAgEJAAAAAAABAQkAzMzMzM3NEQJqZm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\",\"order\":\"little\",\"shape\":[68]}},\"selected\":{\"id\":\"1593\"},\"selection_policy\":{\"id\":\"1592\"}},\"id\":\"1517\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"click_policy\":\"hide\",\"coordinates\":null,\"group\":null,\"items\":[{\"id\":\"1536\"},{\"id\":\"1537\"},{\"id\":\"1538\"}],\"location\":\"center\"},\"id\":\"1535\",\"type\":\"Legend\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#ff7f0e\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#ff7f0e\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#ff7f0e\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1525\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1496\",\"type\":\"BasicTicker\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"hatch_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1518\",\"type\":\"Circle\"},{\"attributes\":{\"axis\":{\"id\":\"1495\"},\"coordinates\":null,\"group\":null,\"ticker\":null},\"id\":\"1498\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1592\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"bottom_units\":\"screen\",\"coordinates\":null,\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"group\":null,\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"syncable\":false,\"top_units\":\"screen\"},\"id\":\"1509\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1504\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1596\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1523\"},\"glyph\":{\"id\":\"1524\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1526\"},\"nonselection_glyph\":{\"id\":\"1525\"},\"view\":{\"id\":\"1528\"}},\"id\":\"1527\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis_label\":\"flipper length (mm)\",\"coordinates\":null,\"formatter\":{\"id\":\"1587\"},\"group\":null,\"major_label_policy\":{\"id\":\"1588\"},\"ticker\":{\"id\":\"1500\"}},\"id\":\"1499\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1593\",\"type\":\"Selection\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#1f77b4\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1520\",\"type\":\"Circle\"},{\"attributes\":{\"axis\":{\"id\":\"1499\"},\"coordinates\":null,\"dimension\":1,\"group\":null,\"ticker\":null},\"id\":\"1502\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1597\",\"type\":\"Selection\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1519\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1500\",\"type\":\"BasicTicker\"},{\"attributes\":{\"label\":{\"value\":\"Adelie\"},\"renderers\":[{\"id\":\"1521\"}]},\"id\":\"1536\",\"type\":\"LegendItem\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1517\"},\"glyph\":{\"id\":\"1518\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1520\"},\"nonselection_glyph\":{\"id\":\"1519\"},\"view\":{\"id\":\"1522\"}},\"id\":\"1521\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1508\",\"type\":\"HelpTool\"},{\"attributes\":{\"label\":{\"value\":\"Gentoo\"},\"renderers\":[{\"id\":\"1533\"}]},\"id\":\"1538\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1503\",\"type\":\"PanTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#2ca02c\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#2ca02c\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#2ca02c\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1532\",\"type\":\"Circle\"},{\"attributes\":{\"overlay\":{\"id\":\"1509\"}},\"id\":\"1505\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#2ca02c\"},\"hatch_alpha\":{\"value\":0.1},\"hatch_color\":{\"value\":\"#2ca02c\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#2ca02c\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1531\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1506\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1507\",\"type\":\"ResetTool\"},{\"attributes\":{\"coordinates\":null,\"data_source\":{\"id\":\"1529\"},\"glyph\":{\"id\":\"1530\"},\"group\":null,\"hover_glyph\":null,\"muted_glyph\":{\"id\":\"1532\"},\"nonselection_glyph\":{\"id\":\"1531\"},\"view\":{\"id\":\"1534\"}},\"id\":\"1533\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"tools\":[{\"id\":\"1503\"},{\"id\":\"1504\"},{\"id\":\"1505\"},{\"id\":\"1506\"},{\"id\":\"1507\"},{\"id\":\"1508\"}]},\"id\":\"1510\",\"type\":\"Toolbar\"},{\"attributes\":{\"label\":{\"value\":\"Chinstrap\"},\"renderers\":[{\"id\":\"1527\"}]},\"id\":\"1537\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1587\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"data\":{\"x\":{\"__ndarray__\":\"zczMzMzMR0AAAAAAAEBFQDMzMzMzc0RAZmZmZmZmSkAzMzMzM7NGQM3MzMzMzEhAAAAAAABASECamZmZmZlIQGZmZmZmZklAMzMzMzPzSUAAAAAAAABKQAAAAAAAAEpAzczMzMzMRkCamZmZmdlGQDMzMzMzc0dAmpmZmZnZRkBmZmZmZqZJQGZmZmZmpkhAmpmZmZkZSUBmZmZmZqZJQM3MzMzMTElAAAAAAABARUCamZmZmdlJQM3MzMzMTEdAAAAAAADASkBmZmZmZuZIQAAAAAAAAE1AmpmZmZlZSUAAAAAAAABKQGZmZmZmZklAmpmZmZkZR0AzMzMzMzNFQDMzMzMzc0lAmpmZmZlZR0AAAAAAAIBIQJqZmZmZmUZAAAAAAACASEAAAAAAAEBHQAAAAAAAQElAzczMzMwMSUBmZmZmZqZJQJqZmZmZGUpAAAAAAACAR0CamZmZmZlGQGZmZmZmJklAZmZmZmZmR0AAAAAAAMBJQDMzMzMzM0dAMzMzMzPzRkCamZmZmZlFQJqZmZmZWUpAzczMzMwMSEAAAAAAAMBHQDMzMzMzM0dAmpmZmZkZSUAAAAAAAMBFQJqZmZmZ2UhAAAAAAAAASUCamZmZmRlLQAAAAAAAwEhAZmZmZmbmS0AAAAAAAMBGQDMzMzMzc0lAAAAAAACASUAzMzMzM7NJQAAAAAAAQElAzczMzMwMR0AAAAAAAABHQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"y\":{\"__ndarray__\":\"AAAAAABgaEAAAAAAAGBnQAAAAAAAYGdAAAAAAACgaUAAAAAAAIBnQAAAAAAAIGhAAAAAAADgZ0AAAAAAAGBoQAAAAAAAQGpAAAAAAADAaUAAAAAAACBpQAAAAAAAQGpAAAAAAABAaEAAAAAAACBoQAAAAAAAAGhAAAAAAABgaEAAAAAAACBoQAAAAAAAYGlAAAAAAABAaUAAAAAAAKBoQAAAAAAAIGhAAAAAAABgZ0AAAAAAAEBoQAAAAAAAIGhAAAAAAACgaUAAAAAAAMBoQAAAAAAAoGZAAAAAAABgaUAAAAAAAKBoQAAAAAAAIGlAAAAAAABgZ0AAAAAAAKBmQAAAAAAAgGhAAAAAAABgaEAAAAAAAIBqQAAAAAAAwGhAAAAAAABAakAAAAAAAABoQAAAAAAAIGlAAAAAAADAZ0AAAAAAAMBoQAAAAAAAoGhAAAAAAAAgZ0AAAAAAAOBnQAAAAAAAoGhAAAAAAACgZ0AAAAAAAGBnQAAAAAAA4GdAAAAAAADAZ0AAAAAAAGBnQAAAAAAAoGhAAAAAAADgaEAAAAAAAOBoQAAAAAAAwGdAAAAAAADAaEAAAAAAAEBpQAAAAAAAYGhAAAAAAACAaEAAAAAAACBpQAAAAAAAAGlAAAAAAADgaUAAAAAAAIBoQAAAAAAAgGhAAAAAAABgaUAAAAAAACBpQAAAAAAAAGlAAAAAAABAZkAAAAAAAGBoQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]}},\"selected\":{\"id\":\"1595\"},\"selection_policy\":{\"id\":\"1594\"}},\"id\":\"1523\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"source\":{\"id\":\"1529\"}},\"id\":\"1534\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1594\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1588\",\"type\":\"AllLabels\"},{\"attributes\":{\"fill_color\":{\"value\":\"#ff7f0e\"},\"hatch_color\":{\"value\":\"#ff7f0e\"},\"line_color\":{\"value\":\"#ff7f0e\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1524\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1595\",\"type\":\"Selection\"},{\"attributes\":{\"data\":{\"x\":{\"__ndarray__\":\"MzMzMzMzSEBmZmZmZiZHQAAAAAAAwEdAmpmZmZlZSECamZmZmVlIQM3MzMzMzEhAZmZmZmamSECamZmZmZlIQAAAAAAAwEZAZmZmZmZmSEAzMzMzMzNHQM3MzMzMTEhAAAAAAABAR0BmZmZmZmZJQJqZmZmZ2UZAAAAAAAAASUCamZmZmVlFQDMzMzMzc0ZAAAAAAADASECamZmZmZlGQAAAAAAAAElAMzMzMzNzREAzMzMzM7NKQM3MzMzMDElAzczMzMyMSUAAAAAAAIBIQDMzMzMzc0VAAAAAAABASUAAAAAAAABJQAAAAAAAQEpAmpmZmZkZR0BmZmZmZmZHQM3MzMzMjEtAzczMzMwMR0AAAAAAAMBGQM3MzMzMjEhAzczMzMwMSkAAAAAAAEBHQAAAAAAAQEZAAAAAAABARkAAAAAAAMBGQDMzMzMzM0ZAmpmZmZmZR0CamZmZmZlGQM3MzMzMDEhAZmZmZmamRkCamZmZmVlIQM3MzMzMTEdAZmZmZmamRUCamZmZmZlFQAAAAAAAwEVAmpmZmZmZRkCamZmZmRlIQJqZmZmZGUdAAAAAAAAARkDNzMzMzAxHQGZmZmZmZkVAzczMzMxMRUBmZmZmZmZJQJqZmZmZGUpAAAAAAABAR0CamZmZmRlJQJqZmZmZGUhAMzMzMzMzSEBmZmZmZmZHQDMzMzMz80tAAAAAAABARkBmZmZmZuZGQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]},\"y\":{\"__ndarray__\":\"AAAAAACAa0AAAAAAAOBqQAAAAAAAIGpAAAAAAAAAakAAAAAAAEBqQAAAAAAAAGtAAAAAAAAga0AAAAAAAKBrQAAAAAAAgGtAAAAAAADAa0AAAAAAAABrQAAAAAAAwGxAAAAAAABAakAAAAAAAEBsQAAAAAAAwGpAAAAAAAAAbEAAAAAAAABqQAAAAAAAoGpAAAAAAACgbEAAAAAAAOBqQAAAAAAAgGtAAAAAAADAakAAAAAAAGBrQAAAAAAAIGxAAAAAAAAgbEAAAAAAAABrQAAAAAAA4GpAAAAAAADAa0AAAAAAAEBrQAAAAAAAoGtAAAAAAACga0AAAAAAAOBqQAAAAAAAwGxAAAAAAADgakAAAAAAAIBqQAAAAAAAgGpAAAAAAADAbEAAAAAAAKBqQAAAAAAAwGpAAAAAAAAAa0AAAAAAAEBqQAAAAAAAYGtAAAAAAADgakAAAAAAAOBqQAAAAAAAIGpAAAAAAABAakAAAAAAAMBrQAAAAAAAQGpAAAAAAAAgakAAAAAAAABqQAAAAAAAoGpAAAAAAACAakAAAAAAAEBqQAAAAAAAIGpAAAAAAAAAakAAAAAAAGBqQAAAAAAAIGpAAAAAAACgakAAAAAAAIBsQAAAAAAAgGxAAAAAAAAga0AAAAAAAEBrQAAAAAAAoGtAAAAAAACgakAAAAAAAOBqQAAAAAAAgGxAAAAAAAAga0AAAAAAAEBqQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[68]}},\"selected\":{\"id\":\"1597\"},\"selection_policy\":{\"id\":\"1596\"}},\"id\":\"1529\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1487\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fill_color\":{\"value\":\"#2ca02c\"},\"hatch_color\":{\"value\":\"#2ca02c\"},\"line_color\":{\"value\":\"#2ca02c\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1530\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1590\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"axis_label\":\"bill length (mm)\",\"coordinates\":null,\"formatter\":{\"id\":\"1590\"},\"group\":null,\"major_label_policy\":{\"id\":\"1591\"},\"ticker\":{\"id\":\"1496\"}},\"id\":\"1495\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1493\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1489\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.2},\"fill_color\":{\"value\":\"#ff7f0e\"},\"hatch_alpha\":{\"value\":0.2},\"hatch_color\":{\"value\":\"#ff7f0e\"},\"line_alpha\":{\"value\":0.2},\"line_color\":{\"value\":\"#ff7f0e\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1526\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1491\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1591\",\"type\":\"AllLabels\"},{\"attributes\":{\"coordinates\":null,\"group\":null},\"id\":\"1584\",\"type\":\"Title\"},{\"attributes\":{\"source\":{\"id\":\"1523\"}},\"id\":\"1528\",\"type\":\"CDSView\"}],\"root_ids\":[\"1486\"]},\"title\":\"Bokeh Application\",\"version\":\"2.4.3\"}};\n", " const render_items = [{\"docid\":\"3c278beb-0c4b-4a08-a148-5229d0a681f7\",\"root_ids\":[\"1486\"],\"roots\":{\"1486\":\"08f1bbbd-03f4-4d4e-bd51-424f145862ef\"}}];\n", " root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n", " }\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " } else {\n", " let attempts = 0;\n", " const timer = setInterval(function(root) {\n", " if (root.Bokeh !== undefined) {\n", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1486" } }, "output_type": "display_data" } ], "source": [ "# Set up figure\n", "p = bokeh.plotting.figure(\n", " frame_width=300,\n", " frame_height=300,\n", " x_axis_label=\"bill length (mm)\",\n", " y_axis_label=\"flipper length (mm)\",\n", " toolbar_location=\"above\",\n", ")\n", "\n", "# Build legend as we populate glyphs\n", "legend_items = []\n", "for color, species in zip(bokeh.palettes.Category10_3, df[\"species\"].unique()):\n", " # Which species\n", " species_inds = df[\"species\"] == species\n", "\n", " # Slice out bill and flipper lengths for species\n", " bill_length = df.loc[(df[\"variable\"] == \"bill_length_mm\") & species_inds, \"value\"]\n", " flipper_length = df.loc[(df[\"variable\"] == \"flipper_length_mm\") & species_inds, \"value\"]\n", "\n", " # Populate glyph\n", " glyph = p.circle(bill_length, flipper_length, color=color)\n", " legend_items.append((species, [glyph]))\n", "\n", "# Build and place legend\n", "legend = bokeh.models.Legend(items=legend_items, location=\"center\")\n", "p.add_layout(legend, \"right\")\n", "p.legend.click_policy = \"hide\"\n", "\n", "bokeh.io.show(p)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This works fine, but is more cumbersome and therefore prone to error because we cannot use a groupby operation. The moral of the story is that you should tidy your data, but you should think carefully about in what way your data are tidy." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Computing environment" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python implementation: CPython\n", "Python version : 3.9.13\n", "IPython version : 8.4.0\n", "\n", "numpy : 1.21.5\n", "pandas : 1.4.3\n", "bokeh : 2.4.3\n", "iqplot : 0.3.2\n", "jupyterlab: 3.4.4\n", "\n" ] } ], "source": [ "%load_ext watermark\n", "%watermark -v -p numpy,pandas,bokeh,iqplot,jupyterlab" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.13" } }, "nbformat": 4, "nbformat_minor": 4 }