{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Making a data frame wide\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": [ "#| code-fold: true\n", "\n", "# Colab setup ------------------\n", "import os, sys, subprocess\n", "if \"google.colab\" in sys.modules:\n", " cmd = \"pip install --upgrade polars 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", " \n", " Loading BokehJS ...\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "'use strict';\n(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\nconst 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 function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\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\n // Clean up Bokeh references\n if (id != null) {\n drop(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 drop(id)\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(error = null) {\n const el = document.getElementById(\"ffa1f309-ab79-4dbd-b98a-db704d19e1e5\");\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.8.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.8.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.8.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.8.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.8.0.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {display_loaded(error);throw error;\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(\"ffa1f309-ab79-4dbd-b98a-db704d19e1e5\")).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": "" }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import polars as pl\n", "\n", "import bebi103\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 unpivoting a data frame can bring it to tidy format, but a tall format is often not the only tidy option nor the easiest to work with. 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), to demonstrate. 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://gormankb.github.io/).\n", "\n", "As we work toward getting the data in a useful tidy format, we will learn some additional wrangling techniques." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exploring the data set\n", "\n", "First, let's take a look at the data set stored in the CSV file." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gentoo,Gentoo,Gentoo,Gentoo,Adelie,Adelie,Adelie,Adelie,Chinstrap,Chinstrap,Chinstrap,Chinstrap\n", "bill_depth_mm,bill_length_mm,flipper_length_mm,body_mass_g,bill_depth_mm,bill_length_mm,flipper_length_mm,body_mass_g,bill_depth_mm,bill_length_mm,flipper_length_mm,body_mass_g\n", "16.3,48.4,220.0,5400.0,18.5,36.8,193.0,3500.0,18.3,47.6,195.0,3850.0\n", "15.8,46.3,215.0,5050.0,16.9,37.0,185.0,3000.0,16.7,42.5,187.0,3350.0\n", "14.2,47.5,209.0,4600.0,19.5,42.0,200.0,4050.0,16.6,40.9,187.0,3200.0\n", "15.7,48.7,208.0,5350.0,18.3,42.7,196.0,4075.0,20.0,52.8,205.0,4550.0\n", "14.1,48.7,210.0,4450.0,18.0,35.7,202.0,3550.0,18.7,45.4,188.0,3525.0\n", "15.0,49.6,216.0,4750.0,19.1,39.8,184.0,4650.0,18.2,49.6,193.0,3775.0\n", "15.7,49.3,217.0,5850.0,18.4,40.8,195.0,3900.0,17.5,48.5,191.0,3400.0\n", "15.2,49.2,221.0,6300.0,18.4,36.6,184.0,3475.0,18.2,49.2,195.0,4400.0\n" ] } ], "source": [ "!head ../data/penguins_subset.csv" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We see that we have *two* header rows. The first gives the species and the second the quantity that is being measured. Apparently, then, each row of data has information for three different penguins, one from each species. This is not a tidy data set!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Reading the data set into a Polars data frame\n", "\n", "We start by naively reading this data set using `pl.read_csv()`." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (5, 12)
GentooGentoo_duplicated_0Gentoo_duplicated_1Gentoo_duplicated_2AdelieAdelie_duplicated_0Adelie_duplicated_1Adelie_duplicated_2ChinstrapChinstrap_duplicated_0Chinstrap_duplicated_1Chinstrap_duplicated_2
strstrstrstrstrstrstrstrstrstrstrstr
"bill_depth_mm""bill_length_mm""flipper_length_mm""body_mass_g""bill_depth_mm""bill_length_mm""flipper_length_mm""body_mass_g""bill_depth_mm""bill_length_mm""flipper_length_mm""body_mass_g"
"16.3""48.4""220.0""5400.0""18.5""36.8""193.0""3500.0""18.3""47.6""195.0""3850.0"
"15.8""46.3""215.0""5050.0""16.9""37.0""185.0""3000.0""16.7""42.5""187.0""3350.0"
"14.2""47.5""209.0""4600.0""19.5""42.0""200.0""4050.0""16.6""40.9""187.0""3200.0"
"15.7""48.7""208.0""5350.0""18.3""42.7""196.0""4075.0""20.0""52.8""205.0""4550.0"
" ], "text/plain": [ "shape: (5, 12)\n", "┌───────────┬───────────┬───────────┬───────────┬───┬───────────┬───────────┬───────────┬──────────┐\n", "│ Gentoo ┆ Gentoo_du ┆ Gentoo_du ┆ Gentoo_du ┆ … ┆ Chinstrap ┆ Chinstrap ┆ Chinstrap ┆ Chinstra │\n", "│ --- ┆ plicated_ ┆ plicated_ ┆ plicated_ ┆ ┆ --- ┆ _duplicat ┆ _duplicat ┆ p_duplic │\n", "│ str ┆ 0 ┆ 1 ┆ 2 ┆ ┆ str ┆ ed_0 ┆ ed_1 ┆ ated_2 │\n", "│ ┆ --- ┆ --- ┆ --- ┆ ┆ ┆ --- ┆ --- ┆ --- │\n", "│ ┆ str ┆ str ┆ str ┆ ┆ ┆ str ┆ str ┆ str │\n", "╞═══════════╪═══════════╪═══════════╪═══════════╪═══╪═══════════╪═══════════╪═══════════╪══════════╡\n", "│ bill_dept ┆ bill_leng ┆ flipper_l ┆ body_mass ┆ … ┆ bill_dept ┆ bill_leng ┆ flipper_l ┆ body_mas │\n", "│ h_mm ┆ th_mm ┆ ength_mm ┆ _g ┆ ┆ h_mm ┆ th_mm ┆ ength_mm ┆ s_g │\n", "│ 16.3 ┆ 48.4 ┆ 220.0 ┆ 5400.0 ┆ … ┆ 18.3 ┆ 47.6 ┆ 195.0 ┆ 3850.0 │\n", "│ 15.8 ┆ 46.3 ┆ 215.0 ┆ 5050.0 ┆ … ┆ 16.7 ┆ 42.5 ┆ 187.0 ┆ 3350.0 │\n", "│ 14.2 ┆ 47.5 ┆ 209.0 ┆ 4600.0 ┆ … ┆ 16.6 ┆ 40.9 ┆ 187.0 ┆ 3200.0 │\n", "│ 15.7 ┆ 48.7 ┆ 208.0 ┆ 5350.0 ┆ … ┆ 20.0 ┆ 52.8 ┆ 205.0 ┆ 4550.0 │\n", "└───────────┴───────────┴───────────┴───────────┴───┴───────────┴───────────┴───────────┴──────────┘" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pl.read_csv(os.path.join(data_path, \"penguins_subset.csv\"))\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ooof! This is nasty. The second header row is included with the data, which results in inferring every column data type to be a string. Polars only allows for a single header row, so we cannot load this data set.\n", "\n", "This is a fairly common occurrence with human-made tabular data. Researchers will have **hierarchical column headings**. In this case, the first header row is species and the second is the quantity that is being measured for the respective species. (Note that I did this intentionally for instructional purposes; this is not what the original penguins data set had.)\n", "\n", "To convert this type of structure into a tidy format, we can perform an unpivoting operation where each of the levels of the hierarchical column headings become rows. Polars will not do this for you, since it forbids hierarchical column headings (hierarchical indexing is not a good idea, in my opinion, so I see why Polars forbids it). I therefore wrote a function for the bebi103 package that takes a CSV file, possibly with a hierarchical index, and unpivots it to give a new CSV file. We can use this on the penguins data set and then load in the result." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (10, 4)
penguin_idspeciesquantityvalue
i64strstrf64
0"Gentoo""bill_depth_mm"16.3
0"Gentoo""bill_length_mm"48.4
0"Gentoo""flipper_length_mm"220.0
0"Gentoo""body_mass_g"5400.0
0"Adelie""bill_depth_mm"18.5
0"Adelie""bill_length_mm"36.8
0"Adelie""flipper_length_mm"193.0
0"Adelie""body_mass_g"3500.0
0"Chinstrap""bill_depth_mm"18.3
0"Chinstrap""bill_length_mm"47.6
" ], "text/plain": [ "shape: (10, 4)\n", "┌────────────┬───────────┬───────────────────┬────────┐\n", "│ penguin_id ┆ species ┆ quantity ┆ value │\n", "│ --- ┆ --- ┆ --- ┆ --- │\n", "│ i64 ┆ str ┆ str ┆ f64 │\n", "╞════════════╪═══════════╪═══════════════════╪════════╡\n", "│ 0 ┆ Gentoo ┆ bill_depth_mm ┆ 16.3 │\n", "│ 0 ┆ Gentoo ┆ bill_length_mm ┆ 48.4 │\n", "│ 0 ┆ Gentoo ┆ flipper_length_mm ┆ 220.0 │\n", "│ 0 ┆ Gentoo ┆ body_mass_g ┆ 5400.0 │\n", "│ 0 ┆ Adelie ┆ bill_depth_mm ┆ 18.5 │\n", "│ 0 ┆ Adelie ┆ bill_length_mm ┆ 36.8 │\n", "│ 0 ┆ Adelie ┆ flipper_length_mm ┆ 193.0 │\n", "│ 0 ┆ Adelie ┆ body_mass_g ┆ 3500.0 │\n", "│ 0 ┆ Chinstrap ┆ bill_depth_mm ┆ 18.3 │\n", "│ 0 ┆ Chinstrap ┆ bill_length_mm ┆ 47.6 │\n", "└────────────┴───────────┴───────────────────┴────────┘" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bebi103.utils.unpivot_csv(\n", " os.path.join(data_path, \"penguins_subset.csv\"), \n", " os.path.join(data_path, \"penguins_tall.csv\"),\n", " header_names=['species', 'quantity'],\n", " retain_row_index=True,\n", " row_index_name='penguin_id',\n", " force_overwrite=True\n", ")\n", "\n", "df = pl.read_csv(os.path.join(data_path, \"penguins_tall.csv\"))\n", "\n", "df.head(10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice that we kept the row index in the column `'penguin_id'` to make sure that we didn't lose track of what penguin each measurement was associated with. Note also that each penguin has a unique identifier *when combined with the species*. E.g., Adelie penguin with penguin ID 0 has four measurements associated with it." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pivoting from tall to wide format\n", "\n", "Looking at the melded data frame above, it is very **tall**. Each row only has a single **value**, that is, a single measurement, and every other column in the row is metadata associated with that measurement, specifically which penguin/species and which quantity was being measured.\n", "\n", "While this tall format is tidy, we can imagine using a **wide** format, in which each row is a specific penguin and each column is a quantity measured on that penguin. This is also a tidy format. In some cases, a tall format is more convenient, and in others a wide format is more convenient.\n", "\n", "To convert from a tall to a wide format, we perform a **pivot**. A pivot operation classifies columns of a tall data frame in three ways.\n", "\n", "- The column(s) we pivot **on** gets converted into column *headings* of the pivoted data frame.\n", "- The **value** column's entries get populated under the new column headings determined by the **on** column.\n", "- The **index** column(s) are essentially along for the ride. They are retained as columns. If the index columns are not unique, then you need to specify an aggregating operation that will be applied to the values associated with rows that have like entries in the index column(s).\n", "\n", "Let us now perform the pivot. We want `'quantity'` as the \"on\" column, since it\n", "takes a column or columns of a data frame and converts them to column headings. In this case, the value column is `'value'`, and `'penguin_id'` and `'species'` columns are the index columns. They uniquely define a penguin, so we do not need to provide any aggregating function." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (5, 6)
penguin_idspeciesbill_depth_mmbill_length_mmflipper_length_mmbody_mass_g
i64strf64f64f64f64
0"Gentoo"16.348.4220.05400.0
0"Adelie"18.536.8193.03500.0
0"Chinstrap"18.347.6195.03850.0
1"Gentoo"15.846.3215.05050.0
1"Adelie"16.937.0185.03000.0
" ], "text/plain": [ "shape: (5, 6)\n", "┌────────────┬───────────┬───────────────┬────────────────┬───────────────────┬─────────────┐\n", "│ penguin_id ┆ species ┆ bill_depth_mm ┆ bill_length_mm ┆ flipper_length_mm ┆ body_mass_g │\n", "│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │\n", "│ i64 ┆ str ┆ f64 ┆ f64 ┆ f64 ┆ f64 │\n", "╞════════════╪═══════════╪═══════════════╪════════════════╪═══════════════════╪═════════════╡\n", "│ 0 ┆ Gentoo ┆ 16.3 ┆ 48.4 ┆ 220.0 ┆ 5400.0 │\n", "│ 0 ┆ Adelie ┆ 18.5 ┆ 36.8 ┆ 193.0 ┆ 3500.0 │\n", "│ 0 ┆ Chinstrap ┆ 18.3 ┆ 47.6 ┆ 195.0 ┆ 3850.0 │\n", "│ 1 ┆ Gentoo ┆ 15.8 ┆ 46.3 ┆ 215.0 ┆ 5050.0 │\n", "│ 1 ┆ Adelie ┆ 16.9 ┆ 37.0 ┆ 185.0 ┆ 3000.0 │\n", "└────────────┴───────────┴───────────────┴────────────────┴───────────────────┴─────────────┘" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.pivot(\n", " on='quantity', \n", " index=['penguin_id', 'species'], \n", " values='value'\n", ")\n", "\n", "# Take a look\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Excellent! We now have a wide, but still tidy, data frame.\n", "\n", "The `'penguin_id'` column is dispensable, but we will keep it for now, since we will demonstrate a pivot operation from this wide data frame in a moment." ] }, { "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": 7, "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 = {\"1828ef7c-f057-4bf9-8fa3-c41529d4d1a9\":{\"version\":\"3.8.0\",\"title\":\"Bokeh Application\",\"config\":{\"type\":\"object\",\"name\":\"DocumentConfig\",\"id\":\"p1127\",\"attributes\":{\"notifications\":{\"type\":\"object\",\"name\":\"Notifications\",\"id\":\"p1128\"}}},\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1008\",\"attributes\":{\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1009\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1010\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1017\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1018\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1015\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1048\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1042\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1043\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1044\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/43SWw3CQBBGYQTUAAYwsAb6wB0MYAADGEAABooADGAAAUUABjCAAcocsidpssnOy5c03ck/s5vSUKd5m/4++6H2i+y1G+qgxyjlnMZ/ncZvN5386jFyssxGn6Txua2XHEqOesmp5Kw3+rw0+rw19tqsisa5adnoM1P2pOyhXu5Zudey7EmZW5ljnSV3WXKXJZfyDuslt0bOs0bfizKX8g6UOTXO9co73lTLnpS9KPekzFGWOUY22yx9lb4aa78rfXbZ+P7RL+W6DlRABAAA\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1XRyUmDUQBF4XRgB3ZgB0IKsAM7sAM70JVL3bkzSxeiLlyIaBAJIpo4z4nzHDuQ9w6ci3fzQUj+/72TRoON1s01/7uoC/NlLeXzZe11y1aU763rZN2G8rtN/R2WbSnP2da11bK28txdna7bU97T0fG6feW9B0qFQ+UccdAvO1LO1dX2TllPOeextpbKTpRzn+rsTNmZco9znaq7UO51qRN1V8o9r3Ws7ka5962O1N0pHe6Vc0S6RM7VVzpFzjlQukXO/aB0jNzjUekaudeT0jlyz2ele+TeL8r/EOnwqnSIdIh0eFM6RDq8Kx0iHT6UDpEOn0qHSIcvpUOkw7fSIdLhR+kQ6TBs/gHaIvU9QAQAAA==\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1049\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1050\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1045\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#1f77b3\",\"line_width\":2}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1046\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#1f77b3\",\"line_alpha\":0.1,\"line_width\":2}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1047\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#1f77b3\",\"line_alpha\":0.2,\"line_width\":2}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1057\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1051\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1052\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1053\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1058\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1059\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1054\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1055\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1056\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1066\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1060\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1061\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1062\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1067\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1068\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1063\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":55.9},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1064\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":55.9},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1065\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":55.9},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1075\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1069\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1070\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1071\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/53SWw3CQBCF4RWAAQxgoAbK/QUDGKiBGkAABkAAOiqgCMAABjBAe/5kD9lkkg3z8iWbbmd2ZlKaYmjb9GtaZ5/jFAur49bq/GR1frH32xyFr9hmjo+ljk2o7i3r7eZYWeVpYnlnLO+2ynO2ytNZ+hJLn6yuPepljrGqc7T03eo/73qZk2VPttXqXh9LXwoHyztiqdOSd5dlLyx7YZmzZc6WuVrqtvru+r+8szDtQ9k7S12WvYqlL4csfbPkOWa/Q5/7eEAEAAA=\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1XRyUmDUQBF4XRgB3ZgB0IKsAM7sAM70JVL3bkzSxeiLlyIaBAJIpo4z4nzHDuQ9w6ci3fzQUj+/72TRoON1s01/7uoC/NlLeXzZe11y1aU763rZN2G8rtN/R2WbSnP2da11bK28txdna7bU97T0fG6feW9B0qFQ+UccdAvO1LO1dX2TllPOeextpbKTpRzn+rsTNmZco9znaq7UO51qRN1V8o9r3Ws7ka5962O1N0pHe6Vc0S6RM7VVzpFzjlQukXO/aB0jNzjUekaudeT0jlyz2ele+TeL8r/EOnwqnSIdIh0eFM6RDq8Kx0iHT6UDpEOn0qHSIcvpUOkw7fSIdLhR+kQ6TBs/gHaIvU9QAQAAA==\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1076\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1077\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1072\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#ff7e0e\",\"line_width\":2}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1073\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#ff7e0e\",\"line_alpha\":0.1,\"line_width\":2}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1074\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#ff7e0e\",\"line_alpha\":0.2,\"line_width\":2}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1084\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1078\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1079\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1080\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1085\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1086\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1081\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":33.5},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1082\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":33.5},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1083\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":33.5},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1093\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1087\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1088\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1089\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1094\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1095\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1090\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":46.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1091\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":46.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1092\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":46.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1102\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1096\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1097\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1098\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/43SWw3CQBBGYQRgAAMYqIE+cL8IqAEMYAAbIAADGKgAEIABDGAAOifZQzaZhHn5kiYzu/Nvm+Zbx1nb/NrMi6Oh2tzLeSiN773yfZEax9yUPn3ch9Loe+bGnLfGnNGyGHPGGn0TZe9c9taYs9OY0+khSslZY86pslf2rhyvityj8pRL7hrXuirnKucqOWv0vZSc10XuqeScG3Omyl655K7kruSeyzvkkpuS0//yXyu5Kjkq/62S4+ZvybGyU/ZW7qH0bYu8q3LOvvgBHp+UJ0AEAAA=\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1XRyUmDUQBF4XRgB3ZgB0IKsAM7sAM70JVL3bkzSxeiLlyIaBAJIpo4z4nzHDuQ9w6ci3fzQUj+/72TRoON1s01/7uoC/NlLeXzZe11y1aU763rZN2G8rtN/R2WbSnP2da11bK28txdna7bU97T0fG6feW9B0qFQ+UccdAvO1LO1dX2TllPOeextpbKTpRzn+rsTNmZco9znaq7UO51qRN1V8o9r3Ws7ka5962O1N0pHe6Vc0S6RM7VVzpFzjlQukXO/aB0jNzjUekaudeT0jlyz2ele+TeL8r/EOnwqnSIdIh0eFM6RDq8Kx0iHT6UDpEOn0qHSIcvpUOkw7fSIdLhR+kQ6TBs/gHaIvU9QAQAAA==\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1103\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1104\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1099\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#2ba02b\",\"line_width\":2}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1100\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#2ba02b\",\"line_alpha\":0.1,\"line_width\":2}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1101\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#2ba02b\",\"line_alpha\":0.2,\"line_width\":2}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1111\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1105\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1106\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1107\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1112\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1113\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1108\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1109\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1110\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1120\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1114\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1115\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1116\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1121\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1122\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1117\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":58.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1118\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":58.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1119\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":58.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1016\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1029\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1030\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1031\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1032\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1038\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1037\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"SaveTool\",\"id\":\"p1039\"},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1040\"},{\"type\":\"object\",\"name\":\"HelpTool\",\"id\":\"p1041\"}]}},\"toolbar_location\":\"above\",\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1024\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1025\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1026\"},\"axis_label\":\"ECDF\",\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1027\"}}}],\"right\":[{\"type\":\"object\",\"name\":\"Legend\",\"id\":\"p1123\",\"attributes\":{\"location\":\"center\",\"click_policy\":\"hide\",\"items\":[{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1124\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Gentoo\"},\"renderers\":[{\"id\":\"p1048\"},{\"id\":\"p1066\"},{\"id\":\"p1057\"}]}},{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1125\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Adelie\"},\"renderers\":[{\"id\":\"p1075\"},{\"id\":\"p1093\"},{\"id\":\"p1084\"}]}},{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1126\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Chinstrap\"},\"renderers\":[{\"id\":\"p1102\"},{\"id\":\"p1120\"},{\"id\":\"p1111\"}]}}]}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1019\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1020\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1021\"},\"axis_label\":\"bill length (mm)\",\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1022\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1023\",\"attributes\":{\"axis\":{\"id\":\"p1019\"}}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1028\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1024\"}}}],\"frame_width\":400,\"frame_height\":275}}]}};\n const render_items = [{\"docid\":\"1828ef7c-f057-4bf9-8fa3-c41529d4d1a9\",\"roots\":{\"p1008\":\"dc61a149-7ccf-4b11-8dd5-b9275a740add\"},\"root_ids\":[\"p1008\"]}];\n void 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": "p1008" } }, "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. It is also useful to have a hover tool that shows bill depth and body mass." ] }, { "cell_type": "code", "execution_count": 8, "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 = {\"a277cacd-a923-43fc-938f-e62b3c52515d\":{\"version\":\"3.8.0\",\"title\":\"Bokeh Application\",\"config\":{\"type\":\"object\",\"name\":\"DocumentConfig\",\"id\":\"p1210\",\"attributes\":{\"notifications\":{\"type\":\"object\",\"name\":\"Notifications\",\"id\":\"p1211\"}}},\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1135\",\"attributes\":{\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1136\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1137\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1144\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1145\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1142\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1179\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1170\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1171\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1172\"},\"data\":{\"type\":\"map\",\"entries\":[[\"penguin_id\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/w3Dh1YBUAAA0FcSMrKTrOxdRggh/v+f3HvODSGEBx+N+GTUZ2PGTfhi0pRpM76aNWfegkVLln2z4rtVP6xZt2HTlp+27di1Z9+BQ0eOnTh15twvv124dOXaHzdu3fnr3oNH/zx59uK/V2/eAdbKGTkQAQAA\"},\"shape\":[68],\"dtype\":\"int32\",\"order\":\"little\"}],[\"species\",{\"type\":\"ndarray\",\"array\":[\"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\"],\"shape\":[68],\"dtype\":\"object\",\"order\":\"little\"}],[\"bill_depth_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/11RWxGEMAzExlnou3MGIgAdpwMboAk8cXSzYZr87CTNPtpe57/WJsf+VJXfqKRY5TsqyTKq2BxYbI69Zj2QfTTe9fidUZE6Uf2D6TAPsLi9Ovtsuv9pyg9On/non22fOXHO3Nlhtx56yt/TfJ+Ve8wdTZf555784PSL8l8fnoPP9wzuv94cuF9X/WQ6fAeg1+/u37Pc8iew4SACAAA=\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"bill_length_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1VRURWDMAxEAAYwMAM10I81bQEDGMAABiYAA0wABmagAjYBMzADMzDKXcPIT16Sy/UuNSZHsGOOi7dVjuTtfdliCJpfzxzErewvgXhBfwx2pzMe+J5z6zmP2HsL+hXrwWFvYj8V/gOH+RX50YK/jshzBO7G9yfHd6Puo27B2xQ91Dl35PPqB336rlv1gSznvOHhW6jbq37sl7vJ+Z49dayOeOpOTvehN6hu+BHVCx+OfO585+bQjToqn/n/9+0Oe/nt1Nfe/oj9AcKVGlAgAgAA\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"flipper_length_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/3WQ0Q3AIAhEGcVRGMVvZQhHYRRG6ShtU86Ea/TnBT3gPJHnrKkv5BofW1KSijp1LelJ9MesurDar1kH5lnd46BVP3t+1h0+rFLoH/Cj5NdZx/uIeIe/oDyUfGEO56ns65C30/6TrtP97rPKdsqBfP70Q2/WdjhtIAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"body_mass_g\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/2NgAAKJrQ4gimHXZgj9YyOEfrYFQidB+X2bIPStbRB6zg4I3QHVV7AdQsdA1a2AqjsG1R8ANc8Azfw76yD0m82o+rZA5ddB3acFNbdmK6q9TWjqYOIwvgvUPK+tqObCzIH5B2Y/zJ+Cm1DNgbn7E1ScZQOEztiA6o58NHNg9pzZgOpvmDkwc2HhDPMnLLxg8XEAKv4Pas6UjajhHQa19wHUPli8qmxGDQeYP2H+hrkDpo97M9xfAML2qsMgAgAA\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1180\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1181\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1176\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"fill_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"hatch_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1177\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"fill_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1178\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"fill_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1191\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1182\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1183\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1184\"},\"data\":{\"type\":\"map\",\"entries\":[[\"penguin_id\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/w3Dh1YBUAAA0FcSMrKTrOxdRggh/v+f3HvODSGEBx+N+GTUZ2PGTfhi0pRpM76aNWfegkVLln2z4rtVP6xZt2HTlp+27di1Z9+BQ0eOnTh15twvv124dOXaHzdu3fnr3oNH/zx59uK/V2/eAdbKGTkQAQAA\"},\"shape\":[68],\"dtype\":\"int32\",\"order\":\"little\"}],[\"species\",{\"type\":\"ndarray\",\"array\":[\"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\"],\"shape\":[68],\"dtype\":\"object\",\"order\":\"little\"}],[\"bill_depth_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/3VQURFDIQzDxlQMCvuvgOl4OrDBbDwbbzamY4yU9OBu/ekF0qRNCL2q6PGrT9QwcNb31espwEH01XrdMniHsOPdeVMnj0r2bnqX4ep64BXywRPzn/OJPuiGm3BPzO0+kRh8vw/9wf3WfWTbO3IP+GX+4173mz7LXPV8Vp3Ee4btWYhX3bLlK1sekblBR/7kteXfXG/6TQy9u34BesbHXyACAAA=\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"bill_length_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1VRXRnCMAycgBrAAAZmIP0bLxiYgRqYAQRgYAhABwKGAAzUwAywNZf0S17uy0/vLmkpZwQazngAh0yv9YgZ+PPUxmpkLIm+2xH3wOjQvyad575g4v4b/B+8eyard0F9izZ30K1BcTxjFz7RlTzquza3AHfxKXve1Afrdl+Nb83qm/2gPosO4W7e3o/gb+k87Gfi+tj3YB9e9+Y8KJq7Ub8f8wa9k+zJPoDkVc/csWS7t8M/EP6pTuD39AcBBFkhIAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"flipper_length_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/3VRwQ2EMAzzKIySUfohV5giozBKR+kohyAWigX9WE5rx0mB8yzdcOHvRmw3RtYtOfK+9cqpb+JzJM6sT+GRfND3gx9e+1jWY619h/r2qh/ib9R55aBOOCQHfaBze52X97bXvOFVNz/2MCVnY15/f7+ID4SzP/8ndN/Pnv/2+92JIAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"body_mass_g\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/2NgAIKI1Q4giqFgOYResh5CX4PSe6DyWpsgdMU6CK22GpVOWQmh56yA0AxQvgPUHJ1VELp6I4Rm2QChZ21A1fcDKn8Cqv8cVNxnLao4TP0ZqH6YP2Dyj6Dqg9ZA6CtQ/22AimdA9R1ahWo+zP/LN6GGy5dVqLQC1FwpqL4JUHGXZRD6xRpUf8LC4ddKVHmYPli4wsRh9tStRfWv3XJU9bD4gbmnBUqvWIbqHpg/YeENcwcs/GDxZbYBHl4AFGUI6iACAAA=\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1192\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1193\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1188\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"fill_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"hatch_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1189\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"fill_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1190\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"fill_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1203\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1194\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1195\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1196\"},\"data\":{\"type\":\"map\",\"entries\":[[\"penguin_id\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/w3Dh1YBUAAA0FcSMrKTrOxdRggh/v+f3HvODSGEBx+N+GTUZ2PGTfhi0pRpM76aNWfegkVLln2z4rtVP6xZt2HTlp+27di1Z9+BQ0eOnTh15twvv124dOXaHzdu3fnr3oNH/zx59uK/V2/eAdbKGTkQAQAA\"},\"shape\":[68],\"dtype\":\"int32\",\"order\":\"little\"}],[\"species\",{\"type\":\"ndarray\",\"array\":[\"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\"],\"shape\":[68],\"dtype\":\"object\",\"order\":\"little\"}],[\"bill_depth_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/21R0RWAIAhsjbZQYQAGaA7naI1aozVsjeYohdMnL358wHF34F2+2JJQjSvIedQIsrRgq1ufktb3OOcLWZ10fgUfS25Bcjed6PjBQ4p7DFeGnp/Xlw0X5zn0i/Fe5PwN/5OfFfrwR50He/k+cu/7f082ntDvCX7VH3itG39Gjn9JfR53Rh0+Fc99b/Dh3vANv8Cpnrv7k+QF/lcljCACAAA=\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"bill_length_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/12RXRXCMAyFK2AGMICBGsgD9GeAgBqYAQzMxhCAgRmYACYAAzMwA5z23mTnkJeepDfpd9P1UyOKqyFX8TWeFxla9MjnIGvTJeqSvKYaiboM3Z5x73o70Reg/wbOj5a39nfmybmnbPXWf8/Ghz6tk3vpod/I5x7QlYNHOTE/gsOrX9YL543qL1iO93VPfL87ODGXvsdo/e3+TN2gvNyXJ8fO/Uz0V7i3ju8u0fS6H9R1H+pbOW685/9smgfzC05yzPnPFzldlB/NABM8IAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"flipper_length_mm\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/21QwQ0AIQhjFEdxFF+iTuEojsIojnKXk5rQnJ8GKKVW5H2lZflQI65+cHqdnLfB8zqPg+b81GM/t7gvLe6jX7DnuHiu/3rwaahr1Ls6nf7nvEl+5oh6+IeQjindxVxjTugvyhdz49yRMyHfQ07XN/kTx93jfFLezM/16j6F6Ia+IAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"body_mass_g\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/2NgAAKRdQ4gikFnFYRmWAmhj22E0F2rIXTdWgg9AarOACrPsgFC34Gas2Q9hD6wCVW/whoILbEUQresQaVh+jZA7fFZi8qHua8OTXwK1B3boOa8QDPPDOq+pI2o9sHcswfqvhNQf59B8w+MjliNai4sHGD2fUHjp6xENbcFTRym7h3U3BXLILQU1F+/oOoq1qGajx4PMH/A1MHcDwsfh/Wo7oeFE3q8wcyDuQ8YbgDVzptFIAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1204\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1205\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1200\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"fill_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"hatch_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1201\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"fill_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1202\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"bill_length_mm\"},\"y\":{\"type\":\"field\",\"field\":\"flipper_length_mm\"},\"line_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"fill_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1143\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1156\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1157\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1158\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1159\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1165\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1164\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"SaveTool\",\"id\":\"p1166\"},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1167\"},{\"type\":\"object\",\"name\":\"HelpTool\",\"id\":\"p1168\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1169\",\"attributes\":{\"renderers\":\"auto\",\"tooltips\":[[\"bill depth\",\"@bill_depth_mm\"],[\"body mass\",\"@body_mass_g\"]],\"sort_by\":null}}]}},\"toolbar_location\":\"above\",\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1151\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1152\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1153\"},\"axis_label\":\"flipper length (mm)\",\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1154\"}}}],\"right\":[{\"type\":\"object\",\"name\":\"Legend\",\"id\":\"p1206\",\"attributes\":{\"location\":\"center\",\"click_policy\":\"hide\",\"items\":[{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1207\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Gentoo\"},\"renderers\":[{\"id\":\"p1179\"}]}},{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1208\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Adelie\"},\"renderers\":[{\"id\":\"p1191\"}]}},{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1209\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Chinstrap\"},\"renderers\":[{\"id\":\"p1203\"}]}}]}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1146\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1147\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1148\"},\"axis_label\":\"bill length (mm)\",\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1149\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1150\",\"attributes\":{\"axis\":{\"id\":\"p1146\"}}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1155\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1151\"}}}],\"frame_width\":300,\"frame_height\":300}}]}};\n const render_items = [{\"docid\":\"a277cacd-a923-43fc-938f-e62b3c52515d\",\"roots\":{\"p1135\":\"f37112ae-cb42-4739-9de4-db50540d5346\"},\"root_ids\":[\"p1135\"]}];\n void 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": "p1135" } }, "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", " tooltips=[('bill depth', '@bill_depth_mm'), ('body mass', '@body_mass_g')]\n", ")\n", "\n", "# Build legend as we populate glyphs\n", "legend_items = []\n", "for color, ((species,), sub_df) in zip(bokeh.palettes.Category10_3, df.group_by(\"species\")):\n", " glyph = p.scatter(\n", " source=sub_df.to_dict(), x=\"bill_length_mm\", y=\"flipper_length_mm\", color=color\n", " )\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 wide version, each row corresponded to a measurement of a single _penguin_, which had several variables associated with it. In the tall version, each row corresponded to a single _feature_ of a penguin.\n", "\n", "To demonstrate that the tall version is workable, but more cumbersome, we can make the same plots as above. First, we'll unpivot the data frame to make it tall. We need to specify which columns as index columns for the unpivot because we want the `'penguin_id'` and `'species'` columns to remain in the tall data frame (which we did not have to do in the previous lesson)." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "shape: (5, 4)
penguin_idspeciesvariablevalue
i64strstrf64
0"Gentoo""bill_depth_mm"16.3
0"Adelie""bill_depth_mm"18.5
0"Chinstrap""bill_depth_mm"18.3
1"Gentoo""bill_depth_mm"15.8
1"Adelie""bill_depth_mm"16.9
" ], "text/plain": [ "shape: (5, 4)\n", "┌────────────┬───────────┬───────────────┬───────┐\n", "│ penguin_id ┆ species ┆ variable ┆ value │\n", "│ --- ┆ --- ┆ --- ┆ --- │\n", "│ i64 ┆ str ┆ str ┆ f64 │\n", "╞════════════╪═══════════╪═══════════════╪═══════╡\n", "│ 0 ┆ Gentoo ┆ bill_depth_mm ┆ 16.3 │\n", "│ 0 ┆ Adelie ┆ bill_depth_mm ┆ 18.5 │\n", "│ 0 ┆ Chinstrap ┆ bill_depth_mm ┆ 18.3 │\n", "│ 1 ┆ Gentoo ┆ bill_depth_mm ┆ 15.8 │\n", "│ 1 ┆ Adelie ┆ bill_depth_mm ┆ 16.9 │\n", "└────────────┴───────────┴───────────────┴───────┘" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.unpivot(index=[\"penguin_id\", \"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 a filter context to pull out the bill length rows." ] }, { "cell_type": "code", "execution_count": 10, "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 = {\"204e5cba-0e31-4b11-9489-ff1e188db8f0\":{\"version\":\"3.8.0\",\"title\":\"Bokeh Application\",\"config\":{\"type\":\"object\",\"name\":\"DocumentConfig\",\"id\":\"p1346\",\"attributes\":{\"notifications\":{\"type\":\"object\",\"name\":\"Notifications\",\"id\":\"p1347\"}}},\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1227\",\"attributes\":{\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1228\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1229\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1236\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1237\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1234\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1267\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1261\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1262\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1263\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/43SWw3CQBBGYQTUAAYwsAb6wB0MYAADGEAABooADGAAAUUABjCAAcocsidpssnOy5c03ck/s5vSUKd5m/4++6H2i+y1G+qgxyjlnMZ/ncZvN5386jFyssxGn6Txua2XHEqOesmp5Kw3+rw0+rw19tqsisa5adnoM1P2pOyhXu5Zudey7EmZW5ljnSV3WXKXJZfyDuslt0bOs0bfizKX8g6UOTXO9co73lTLnpS9KPekzFGWOUY22yx9lb4aa78rfXbZ+P7RL+W6DlRABAAA\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1XRyUmDUQBF4XRgB3ZgB0IKsAM7sAM70JVL3bkzSxeiLlyIaBAJIpo4z4nzHDuQ9w6ci3fzQUj+/72TRoON1s01/7uoC/NlLeXzZe11y1aU763rZN2G8rtN/R2WbSnP2da11bK28txdna7bU97T0fG6feW9B0qFQ+UccdAvO1LO1dX2TllPOeextpbKTpRzn+rsTNmZco9znaq7UO51qRN1V8o9r3Ws7ka5962O1N0pHe6Vc0S6RM7VVzpFzjlQukXO/aB0jNzjUekaudeT0jlyz2ele+TeL8r/EOnwqnSIdIh0eFM6RDq8Kx0iHT6UDpEOn0qHSIcvpUOkw7fSIdLhR+kQ6TBs/gHaIvU9QAQAAA==\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1268\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1269\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1264\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#1f77b3\",\"line_width\":2}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1265\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#1f77b3\",\"line_alpha\":0.1,\"line_width\":2}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1266\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#1f77b3\",\"line_alpha\":0.2,\"line_width\":2}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1276\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1270\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1271\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1272\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1277\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1278\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1273\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1274\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1275\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1285\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1279\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1280\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1281\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1286\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1287\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1282\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":55.9},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1283\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":55.9},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1284\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":55.9},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b3\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1294\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1288\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1289\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1290\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/53SWw3CQBCF4RWAAQxgoAbK/QUDGKiBGkAABkAAOiqgCMAABjBAe/5kD9lkkg3z8iWbbmd2ZlKaYmjb9GtaZ5/jFAur49bq/GR1frH32xyFr9hmjo+ljk2o7i3r7eZYWeVpYnlnLO+2ynO2ytNZ+hJLn6yuPepljrGqc7T03eo/73qZk2VPttXqXh9LXwoHyztiqdOSd5dlLyx7YZmzZc6WuVrqtvru+r+8szDtQ9k7S12WvYqlL4csfbPkOWa/Q5/7eEAEAAA=\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1XRyUmDUQBF4XRgB3ZgB0IKsAM7sAM70JVL3bkzSxeiLlyIaBAJIpo4z4nzHDuQ9w6ci3fzQUj+/72TRoON1s01/7uoC/NlLeXzZe11y1aU763rZN2G8rtN/R2WbSnP2da11bK28txdna7bU97T0fG6feW9B0qFQ+UccdAvO1LO1dX2TllPOeextpbKTpRzn+rsTNmZco9znaq7UO51qRN1V8o9r3Ws7ka5962O1N0pHe6Vc0S6RM7VVzpFzjlQukXO/aB0jNzjUekaudeT0jlyz2ele+TeL8r/EOnwqnSIdIh0eFM6RDq8Kx0iHT6UDpEOn0qHSIcvpUOkw7fSIdLhR+kQ6TBs/gHaIvU9QAQAAA==\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1295\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1296\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1291\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#ff7e0e\",\"line_width\":2}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1292\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#ff7e0e\",\"line_alpha\":0.1,\"line_width\":2}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1293\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#ff7e0e\",\"line_alpha\":0.2,\"line_width\":2}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1303\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1297\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1298\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1299\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1304\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1305\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1300\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":33.5},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1301\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":33.5},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1302\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":33.5},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1312\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1306\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1307\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1308\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1313\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1314\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1309\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":46.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1310\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":46.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1311\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":46.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7e0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1321\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1315\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1316\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1317\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/43SWw3CQBBGYQRgAAMYqIE+cL8IqAEMYAAbIAADGKgAEIABDGAAOifZQzaZhHn5kiYzu/Nvm+Zbx1nb/NrMi6Oh2tzLeSiN773yfZEax9yUPn3ch9Loe+bGnLfGnNGyGHPGGn0TZe9c9taYs9OY0+khSslZY86pslf2rhyvityj8pRL7hrXuirnKucqOWv0vZSc10XuqeScG3Omyl655K7kruSeyzvkkpuS0//yXyu5Kjkq/62S4+ZvybGyU/ZW7qH0bYu8q3LOvvgBHp+UJ0AEAAA=\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1XRyUmDUQBF4XRgB3ZgB0IKsAM7sAM70JVL3bkzSxeiLlyIaBAJIpo4z4nzHDuQ9w6ci3fzQUj+/72TRoON1s01/7uoC/NlLeXzZe11y1aU763rZN2G8rtN/R2WbSnP2da11bK28txdna7bU97T0fG6feW9B0qFQ+UccdAvO1LO1dX2TllPOeextpbKTpRzn+rsTNmZco9znaq7UO51qRN1V8o9r3Ws7ka5962O1N0pHe6Vc0S6RM7VVzpFzjlQukXO/aB0jNzjUekaudeT0jlyz2ele+TeL8r/EOnwqnSIdIh0eFM6RDq8Kx0iHT6UDpEOn0qHSIcvpUOkw7fSIdLhR+kQ6TBs/gHaIvU9QAQAAA==\"},\"shape\":[136],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1322\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1323\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1318\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#2ba02b\",\"line_width\":2}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1319\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#2ba02b\",\"line_alpha\":0.1,\"line_width\":2}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Line\",\"id\":\"p1320\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":\"#2ba02b\",\"line_alpha\":0.2,\"line_width\":2}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1330\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1324\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1325\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1326\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1331\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1332\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1327\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1328\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1329\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":40.9},\"y\":{\"type\":\"value\",\"value\":0},\"angle\":{\"type\":\"value\",\"value\":3.141592653589793},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1339\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1333\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1334\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1335\"},\"data\":{\"type\":\"map\"}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1340\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1341\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1336\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":58.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1337\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":58.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"line_width\":{\"type\":\"value\",\"value\":2}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Ray\",\"id\":\"p1338\",\"attributes\":{\"x\":{\"type\":\"value\",\"value\":58.0},\"y\":{\"type\":\"value\",\"value\":1},\"line_color\":{\"type\":\"value\",\"value\":\"#2ba02b\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"line_width\":{\"type\":\"value\",\"value\":2}}}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1235\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1248\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1249\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1250\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1251\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1257\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1256\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"SaveTool\",\"id\":\"p1258\"},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1259\"},{\"type\":\"object\",\"name\":\"HelpTool\",\"id\":\"p1260\"}]}},\"toolbar_location\":\"above\",\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1243\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1244\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1245\"},\"axis_label\":\"ECDF\",\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1246\"}}}],\"right\":[{\"type\":\"object\",\"name\":\"Legend\",\"id\":\"p1342\",\"attributes\":{\"location\":\"center\",\"click_policy\":\"hide\",\"items\":[{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1343\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Gentoo\"},\"renderers\":[{\"id\":\"p1267\"},{\"id\":\"p1285\"},{\"id\":\"p1276\"}]}},{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1344\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Adelie\"},\"renderers\":[{\"id\":\"p1294\"},{\"id\":\"p1312\"},{\"id\":\"p1303\"}]}},{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1345\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Chinstrap\"},\"renderers\":[{\"id\":\"p1321\"},{\"id\":\"p1339\"},{\"id\":\"p1330\"}]}}]}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1238\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1239\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1240\"},\"axis_label\":\"bill length (mm)\",\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1241\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1242\",\"attributes\":{\"axis\":{\"id\":\"p1238\"}}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1247\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1243\"}}}],\"frame_width\":400,\"frame_height\":275}}]}};\n const render_items = [{\"docid\":\"204e5cba-0e31-4b11-9489-ff1e188db8f0\",\"roots\":{\"p1227\":\"c3d7cee5-6873-4eb5-9941-079f6f266ddb\"},\"root_ids\":[\"p1227\"]}];\n void 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": "p1227" } }, "output_type": "display_data" } ], "source": [ "bokeh.io.show(\n", " iqplot.ecdf(\n", " data=df.filter(pl.col('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 filtering by hand." ] }, { "cell_type": "code", "execution_count": 11, "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 = {\"d48dd3db-fc9d-4e32-ac2e-d78ed2b04d94\":{\"version\":\"3.8.0\",\"title\":\"Bokeh Application\",\"config\":{\"type\":\"object\",\"name\":\"DocumentConfig\",\"id\":\"p1419\",\"attributes\":{\"notifications\":{\"type\":\"object\",\"name\":\"Notifications\",\"id\":\"p1420\"}}},\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1354\",\"attributes\":{\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1355\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1356\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1363\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1364\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1361\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1394\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1388\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1389\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1390\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/12RXRXCMAyFK2AGMICBGsgD9GeAgBqYAQzMxhCAgRmYACYAAzMwA5z23mTnkJeepDfpd9P1UyOKqyFX8TWeFxla9MjnIGvTJeqSvKYaiboM3Z5x73o70Reg/wbOj5a39nfmybmnbPXWf8/Ghz6tk3vpod/I5x7QlYNHOTE/gsOrX9YL543qL1iO93VPfL87ODGXvsdo/e3+TN2gvNyXJ8fO/Uz0V7i3ju8u0fS6H9R1H+pbOW685/9smgfzC05yzPnPFzldlB/NABM8IAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/21QwQ0AIQhjFEdxFF+iTuEojsIojnKXk5rQnJ8GKKVW5H2lZflQI65+cHqdnLfB8zqPg+b81GM/t7gvLe6jX7DnuHiu/3rwaahr1Ls6nf7nvEl+5oh6+IeQjindxVxjTugvyhdz49yRMyHfQ07XN/kTx93jfFLezM/16j6F6Ia+IAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1395\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1396\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1391\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"fill_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"hatch_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1392\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"fill_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1393\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"fill_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_color\":{\"type\":\"value\",\"value\":\"#1f77b4\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1403\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1397\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1398\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1399\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1VRXRnCMAycgBrAAAZmIP0bLxiYgRqYAQRgYAhABwKGAAzUwAywNZf0S17uy0/vLmkpZwQazngAh0yv9YgZ+PPUxmpkLIm+2xH3wOjQvyad575g4v4b/B+8eyard0F9izZ30K1BcTxjFz7RlTzquza3AHfxKXve1Afrdl+Nb83qm/2gPosO4W7e3o/gb+k87Gfi+tj3YB9e9+Y8KJq7Ub8f8wa9k+zJPoDkVc/csWS7t8M/EP6pTuD39AcBBFkhIAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/3VRwQ2EMAzzKIySUfohV5giozBKR+kohyAWigX9WE5rx0mB8yzdcOHvRmw3RtYtOfK+9cqpb+JzJM6sT+GRfND3gx9e+1jWY619h/r2qh/ib9R55aBOOCQHfaBze52X97bXvOFVNz/2MCVnY15/f7+ID4SzP/8ndN/Pnv/2+92JIAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1404\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1405\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1400\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"fill_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"hatch_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1401\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"fill_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1402\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"fill_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_color\":{\"type\":\"value\",\"value\":\"#ff7f0e\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}},{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1412\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1406\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1407\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1408\"},\"data\":{\"type\":\"map\",\"entries\":[[\"x\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/1VRURWDMAxEAAYwMAM10I81bQEDGMAABiYAA0wABmagAjYBMzADMzDKXcPIT16Sy/UuNSZHsGOOi7dVjuTtfdliCJpfzxzErewvgXhBfwx2pzMe+J5z6zmP2HsL+hXrwWFvYj8V/gOH+RX50YK/jshzBO7G9yfHd6Puo27B2xQ91Dl35PPqB336rlv1gSznvOHhW6jbq37sl7vJ+Z49dayOeOpOTvehN6hu+BHVCx+OfO585+bQjToqn/n/9+0Oe/nt1Nfe/oj9AcKVGlAgAgAA\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}],[\"y\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H4sIAAEAAAAC/3WQ0Q3AIAhEGcVRGMVvZQhHYRRG6ShtU86Ea/TnBT3gPJHnrKkv5BofW1KSijp1LelJ9MesurDar1kH5lnd46BVP3t+1h0+rFLoH/Cj5NdZx/uIeIe/oDyUfGEO56ns65C30/6TrtP97rPKdsqBfP70Q2/WdjhtIAIAAA==\"},\"shape\":[68],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1413\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1414\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1409\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"fill_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"hatch_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"}}},\"nonselection_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1410\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.1},\"fill_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.1},\"hatch_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.1}}},\"muted_glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1411\",\"attributes\":{\"x\":{\"type\":\"field\",\"field\":\"x\"},\"y\":{\"type\":\"field\",\"field\":\"y\"},\"line_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"line_alpha\":{\"type\":\"value\",\"value\":0.2},\"fill_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"fill_alpha\":{\"type\":\"value\",\"value\":0.2},\"hatch_color\":{\"type\":\"value\",\"value\":\"#2ca02c\"},\"hatch_alpha\":{\"type\":\"value\",\"value\":0.2}}}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1362\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1375\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1376\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1377\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1378\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1384\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1383\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"SaveTool\",\"id\":\"p1385\"},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1386\"},{\"type\":\"object\",\"name\":\"HelpTool\",\"id\":\"p1387\"}]}},\"toolbar_location\":\"above\",\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1370\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1371\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1372\"},\"axis_label\":\"flipper length (mm)\",\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1373\"}}}],\"right\":[{\"type\":\"object\",\"name\":\"Legend\",\"id\":\"p1415\",\"attributes\":{\"location\":\"center\",\"click_policy\":\"hide\",\"items\":[{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1416\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Chinstrap\"},\"renderers\":[{\"id\":\"p1394\"}]}},{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1417\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Adelie\"},\"renderers\":[{\"id\":\"p1403\"}]}},{\"type\":\"object\",\"name\":\"LegendItem\",\"id\":\"p1418\",\"attributes\":{\"label\":{\"type\":\"value\",\"value\":\"Gentoo\"},\"renderers\":[{\"id\":\"p1412\"}]}}]}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1365\",\"attributes\":{\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1366\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1367\"},\"axis_label\":\"bill length (mm)\",\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1368\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1369\",\"attributes\":{\"axis\":{\"id\":\"p1365\"}}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1374\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1370\"}}}],\"frame_width\":300,\"frame_height\":300}}]}};\n const render_items = [{\"docid\":\"d48dd3db-fc9d-4e32-ac2e-d78ed2b04d94\",\"roots\":{\"p1354\":\"f5cba77f-93fb-4e68-a986-4d8d841b0169\"},\"root_ids\":[\"p1354\"]}];\n void 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": "p1354" } }, "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", "# Expressions for filtering\n", "bill_length = pl.col('variable') == \"bill_length_mm\"\n", "flipper_length = pl.col('variable') == \"flipper_length_mm\"\n", "\n", "# Build legend as we populate glyphs\n", "legend_items = []\n", "for color, ((species,), sub_df) in zip(bokeh.palettes.Category10_3, df.group_by('species')):\n", " # Slice out bill and flipper lengths for species\n", " bill = sub_df.filter(bill_length).get_column('value').to_numpy()\n", " flipper = sub_df.filter(flipper_length).get_column('value').to_numpy()\n", " \n", " # Populate glyph\n", " glyph = p.scatter(bill, flipper, 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. Importantly, we could not use a column data source in the plot to enable display of more data upon hover. The moral of the story is that you should tidy your data, but you should think carefully about in what way you want your data to be tidy." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Computing environment" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python implementation: CPython\n", "Python version : 3.13.7\n", "IPython version : 9.5.0\n", "\n", "numpy : 2.2.6\n", "pandas : 2.3.2\n", "bokeh : 3.8.0\n", "iqplot : 0.3.7\n", "jupyterlab: 4.4.7\n", "\n" ] } ], "source": [ "%load_ext watermark\n", "%watermark -v -p numpy,pandas,bokeh,iqplot,jupyterlab" ] } ], "metadata": { "kernelspec": { "display_name": "default", "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.13.7" } }, "nbformat": 4, "nbformat_minor": 4 }