{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Baby Names"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
"
],
"text/plain": [
""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import addutils.toc ; addutils.toc.js(ipy_notebook=True)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
"
\n",
"
Loading BokehJS ...\n",
"
"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function(root) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = true;\n",
"\n",
" if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
" root._bokeh_onload_callbacks = [];\n",
" root._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
" var JS_MIME_TYPE = 'application/javascript';\n",
" var HTML_MIME_TYPE = 'text/html';\n",
" var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
" var CLASS_NAME = 'output_bokeh rendered_html';\n",
"\n",
" /**\n",
" * Render data to the DOM node\n",
" */\n",
" function render(props, node) {\n",
" var 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",
" var cell = handle.cell;\n",
"\n",
" var id = cell.output_area._bokeh_element_id;\n",
" var server_id = cell.output_area._bokeh_server_id;\n",
" // Clean up Bokeh references\n",
" if (id !== undefined) {\n",
" Bokeh.index[id].model.document.clear();\n",
" delete Bokeh.index[id];\n",
" }\n",
"\n",
" if (server_id !== undefined) {\n",
" // Clean up Bokeh references\n",
" var cmd = \"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, {\n",
" iopub: {\n",
" output: function(msg) {\n",
" var element_id = msg.content.text.trim();\n",
" Bokeh.index[element_id].model.document.clear();\n",
" delete Bokeh.index[element_id];\n",
" }\n",
" }\n",
" });\n",
" // Destroy server and session\n",
" var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
" cell.notebook.kernel.execute(cmd);\n",
" }\n",
" }\n",
"\n",
" /**\n",
" * Handle when a new output is added\n",
" */\n",
" function handleAddOutput(event, handle) {\n",
" var output_area = handle.output_area;\n",
" var output = handle.output;\n",
"\n",
" // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
" if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
" return\n",
" }\n",
"\n",
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
"\n",
" if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
" toinsert[0].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",
" var bk_div = document.createElement(\"div\");\n",
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
" var script_attrs = bk_div.children[0].attributes;\n",
" for (var i = 0; i < script_attrs.length; i++) {\n",
" toinsert[0].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\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",
" var 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",
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
" render(props, toinsert[0]);\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",
" var events = require('base/js/events');\n",
" var 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",
"\n",
" \n",
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
" root._bokeh_timeout = Date.now() + 5000;\n",
" root._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"\\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",
" \"- re-rerun `output_notebook()` to attempt to load from CDN again, or
\\n\"+\n",
" \"- use INLINE resources instead, as so:
\\n\"+\n",
" \"
\\n\"+\n",
" \"
\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"\\n\"+\n",
" \"
\"}};\n",
"\n",
" function display_loaded() {\n",
" var el = document.getElementById(\"055f4df9-4d8e-423b-946e-422279c4da24\");\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" if (el != null) {\n",
" el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
" }\n",
" } else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
"\n",
" function run_callbacks() {\n",
" try {\n",
" root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
" }\n",
" finally {\n",
" delete root._bokeh_onload_callbacks\n",
" }\n",
" console.info(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(js_urls, callback) {\n",
" root._bokeh_onload_callbacks.push(callback);\n",
" if (root._bokeh_is_loading > 0) {\n",
" console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" root._bokeh_is_loading = js_urls.length;\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var s = document.createElement('script');\n",
" s.src = url;\n",
" s.async = false;\n",
" s.onreadystatechange = s.onload = function() {\n",
" root._bokeh_is_loading--;\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
" run_callbacks()\n",
" }\n",
" };\n",
" s.onerror = function() {\n",
" console.warn(\"failed to load library \" + url);\n",
" };\n",
" console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
" }\n",
" };var element = document.getElementById(\"055f4df9-4d8e-423b-946e-422279c4da24\");\n",
" if (element == null) {\n",
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '055f4df9-4d8e-423b-946e-422279c4da24' but no matching script tag was found. \")\n",
" return false;\n",
" }\n",
"\n",
" var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.13.min.js\"];\n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" \n",
" function(Bokeh) {\n",
" \n",
" },\n",
" function(Bokeh) {\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if ((root.Bokeh !== undefined) || (force === true)) {\n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i].call(root, root.Bokeh);\n",
" }if (force === true) {\n",
" display_loaded();\n",
" }} else if (Date.now() < root._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!root._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n",
" var cell = $(document.getElementById(\"055f4df9-4d8e-423b-946e-422279c4da24\")).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (root._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(js_urls, function() {\n",
" console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(window));"
],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"\\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 \"- re-rerun `output_notebook()` to attempt to load from CDN again, or
\\n\"+\n \"- use INLINE resources instead, as so:
\\n\"+\n \"
\\n\"+\n \"
\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"055f4df9-4d8e-423b-946e-422279c4da24\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = js_urls.length;\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var s = document.createElement('script');\n s.src = url;\n s.async = false;\n s.onreadystatechange = s.onload = function() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: all BokehJS libraries loaded\");\n run_callbacks()\n }\n };\n s.onerror = function() {\n console.warn(\"failed to load library \" + url);\n };\n console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.getElementsByTagName(\"head\")[0].appendChild(s);\n }\n };var element = document.getElementById(\"055f4df9-4d8e-423b-946e-422279c4da24\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '055f4df9-4d8e-423b-946e-422279c4da24' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.13.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.13.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.13.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"055f4df9-4d8e-423b-946e-422279c4da24\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(js_urls, function() {\n console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import addutils\n",
"from IPython.display import display\n",
"import bokeh.plotting as bk\n",
"bk.output_notebook()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n"
],
"text/plain": [
""
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"addutils.css_notebook()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1 Load and prepare the data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We downloaded statistics about baby names choosen over years in the U.S. from:\n",
"http://www.babycenter.com/baby-names and we stored them on our example data folder."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" name | \n",
" sex | \n",
" births | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Mary | \n",
" F | \n",
" 7065 | \n",
"
\n",
" \n",
" | 1 | \n",
" Anna | \n",
" F | \n",
" 2604 | \n",
"
\n",
" \n",
" | 2 | \n",
" Emma | \n",
" F | \n",
" 2003 | \n",
"
\n",
" \n",
" | 3 | \n",
" Elizabeth | \n",
" F | \n",
" 1939 | \n",
"
\n",
" \n",
" | 4 | \n",
" Minnie | \n",
" F | \n",
" 1746 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" name sex births\n",
"0 Mary F 7065\n",
"1 Anna F 2604\n",
"2 Emma F 2003\n",
"3 Elizabeth F 1939\n",
"4 Minnie F 1746"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataFolder = 'temp/baby_names/'\n",
"columnNames = ['name', 'sex', 'births']\n",
"\n",
"names1880 = pd.read_csv(dataFolder+'yob1880.txt', names=columnNames)\n",
"names1880.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This shows some of the names choosen during 1880.\n",
"\n",
"Now we want to read all the files in the years that spaces from 1880 to 2011."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"years = range(1880, 2012)\n",
"parts = []\n",
"for year in years:\n",
" path = '{0}yob{1}.txt'.format(dataFolder, year)\n",
" frame = pd.read_csv(path, names=columnNames)\n",
" frame['year'] = year \n",
" parts.append(frame)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now parts is a `python` `list` containing `pandas.DataFrame`(s). Let's create a single `DataFrame` containing all the names."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" name | \n",
" sex | \n",
" births | \n",
" year | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Mary | \n",
" F | \n",
" 7065 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 100000 | \n",
" Ernie | \n",
" F | \n",
" 13 | \n",
" 1912 | \n",
"
\n",
" \n",
" | 200000 | \n",
" Lemoyne | \n",
" M | \n",
" 9 | \n",
" 1922 | \n",
"
\n",
" \n",
" | 300000 | \n",
" Derrell | \n",
" M | \n",
" 43 | \n",
" 1932 | \n",
"
\n",
" \n",
" | 400000 | \n",
" Valentine | \n",
" M | \n",
" 56 | \n",
" 1943 | \n",
"
\n",
" \n",
" | 500000 | \n",
" Neal | \n",
" M | \n",
" 968 | \n",
" 1953 | \n",
"
\n",
" \n",
" | 600000 | \n",
" Konni | \n",
" F | \n",
" 14 | \n",
" 1962 | \n",
"
\n",
" \n",
" | 700000 | \n",
" Howard | \n",
" F | \n",
" 18 | \n",
" 1970 | \n",
"
\n",
" \n",
" | 800000 | \n",
" Tomecca | \n",
" F | \n",
" 6 | \n",
" 1976 | \n",
"
\n",
" \n",
" | 900000 | \n",
" Martrell | \n",
" M | \n",
" 8 | \n",
" 1981 | \n",
"
\n",
" \n",
" | 1000000 | \n",
" Clearence | \n",
" M | \n",
" 6 | \n",
" 1986 | \n",
"
\n",
" \n",
" | 1100000 | \n",
" Indiana | \n",
" F | \n",
" 15 | \n",
" 1991 | \n",
"
\n",
" \n",
" | 1200000 | \n",
" Aminata | \n",
" F | \n",
" 30 | \n",
" 1995 | \n",
"
\n",
" \n",
" | 1300000 | \n",
" Yutaro | \n",
" M | \n",
" 8 | \n",
" 1998 | \n",
"
\n",
" \n",
" | 1400000 | \n",
" Mc | \n",
" F | \n",
" 14 | \n",
" 2002 | \n",
"
\n",
" \n",
" | 1500000 | \n",
" Marshayla | \n",
" F | \n",
" 7 | \n",
" 2005 | \n",
"
\n",
" \n",
" | 1600000 | \n",
" Treonna | \n",
" F | \n",
" 9 | \n",
" 2008 | \n",
"
\n",
" \n",
" | 1700000 | \n",
" Kellsie | \n",
" F | \n",
" 13 | \n",
" 2011 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" name sex births year\n",
"0 Mary F 7065 1880\n",
"100000 Ernie F 13 1912\n",
"200000 Lemoyne M 9 1922\n",
"300000 Derrell M 43 1932\n",
"400000 Valentine M 56 1943\n",
"500000 Neal M 968 1953\n",
"600000 Konni F 14 1962\n",
"700000 Howard F 18 1970\n",
"800000 Tomecca F 6 1976\n",
"900000 Martrell M 8 1981\n",
"1000000 Clearence M 6 1986\n",
"1100000 Indiana F 15 1991\n",
"1200000 Aminata F 30 1995\n",
"1300000 Yutaro M 8 1998\n",
"1400000 Mc F 14 2002\n",
"1500000 Marshayla F 7 2005\n",
"1600000 Treonna F 9 2008\n",
"1700000 Kellsie F 13 2011"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"names = pd.concat(parts, ignore_index=True)\n",
"names[::10**5]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`pandas.concat` concatenates pandas objects along a particular axis. If the optional parameter `ignore_insex` is True, `concat` won't use index values on the concatenation. Values from `0` to `n-1` will be used instead."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2 Pivoting"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`DataFrame.pivot_table` creates a spreadsheet-style pivot table as a DataFrame. `aggfunc` parameter specifies a list of aggregation functions to use on elements, `margins` tells if grandtotal/subtotals are to be added to all columns/rows."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"75fb71eb-9190-43da-b46a-2389fa6ec1f6\":{\"roots\":{\"references\":[{\"attributes\":{},\"id\":\"c3f53777-3988-426b-bbb4-7dc438c2c07e\",\"type\":\"LinearScale\"},{\"attributes\":{\"data_source\":{\"id\":\"114a354b-550f-4895-ad8e-d805f769db3d\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"1d410988-cca1-4dfb-b5e2-eb43e11b8aca\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"8258b7d1-d245-4271-b541-e7b1fdcd4db7\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"bdf43eee-e8ee-4650-80e6-e033e3445e89\",\"type\":\"CDSView\"}},\"id\":\"8289e9dc-0263-4b94-8b20-7f930fe0b02f\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"plot\":{\"id\":\"c48bb04e-017b-40c0-93b1-4d8fb19cc21c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"50793fd1-fd48-4a68-ac1e-68af34e08c9e\",\"type\":\"BasicTicker\"}},\"id\":\"2cfe9137-3689-41eb-a099-674b1e046f1a\",\"type\":\"Grid\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"8258b7d1-d245-4271-b541-e7b1fdcd4db7\",\"type\":\"Line\"},{\"attributes\":{\"axis_label\":\"Total births\",\"formatter\":{\"id\":\"d4d23c33-f9bb-4e94-a255-2efc6f761409\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"c48bb04e-017b-40c0-93b1-4d8fb19cc21c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"179a3e49-3666-406b-9130-74b272db2016\",\"type\":\"BasicTicker\"}},\"id\":\"fea81321-3ded-4f57-b503-e564fed76116\",\"type\":\"LinearAxis\"},{\"attributes\":{\"line_color\":\"magenta\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"1d410988-cca1-4dfb-b5e2-eb43e11b8aca\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"179a3e49-3666-406b-9130-74b272db2016\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"c48bb04e-017b-40c0-93b1-4d8fb19cc21c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"179a3e49-3666-406b-9130-74b272db2016\",\"type\":\"BasicTicker\"}},\"id\":\"15c78ac0-d975-453a-8125-275d806f612b\",\"type\":\"Grid\"},{\"attributes\":{\"below\":[{\"id\":\"a28a7ade-b65d-4ae4-b239-93e94f98669b\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"fea81321-3ded-4f57-b503-e564fed76116\",\"type\":\"LinearAxis\"}],\"plot_height\":300,\"plot_width\":750,\"renderers\":[{\"id\":\"a28a7ade-b65d-4ae4-b239-93e94f98669b\",\"type\":\"LinearAxis\"},{\"id\":\"2cfe9137-3689-41eb-a099-674b1e046f1a\",\"type\":\"Grid\"},{\"id\":\"fea81321-3ded-4f57-b503-e564fed76116\",\"type\":\"LinearAxis\"},{\"id\":\"15c78ac0-d975-453a-8125-275d806f612b\",\"type\":\"Grid\"},{\"id\":\"d830dcb9-e76d-4c18-9ed5-d0cc490f0c4d\",\"type\":\"BoxAnnotation\"},{\"id\":\"d3a9c734-69ed-4c9c-a7d6-d33f3dcbea86\",\"type\":\"Legend\"},{\"id\":\"8289e9dc-0263-4b94-8b20-7f930fe0b02f\",\"type\":\"GlyphRenderer\"},{\"id\":\"5792d5ac-8797-4b28-982b-ba9b6bfdb60d\",\"type\":\"GlyphRenderer\"}],\"title\":null,\"toolbar\":{\"id\":\"ad1db200-1a4f-41cb-9764-a1bb94907eb7\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"a92d30d2-902b-407f-93d7-9af28e485ffa\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"c3f53777-3988-426b-bbb4-7dc438c2c07e\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"636c6332-1d8f-4391-b3f2-a8aeb0c7050c\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"1adf8a79-1557-49f2-9772-93f8f5aede26\",\"type\":\"LinearScale\"}},\"id\":\"c48bb04e-017b-40c0-93b1-4d8fb19cc21c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"line_color\":\"royalblue\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"a5355a89-a0ff-48e7-9d7c-c548420f30b2\",\"type\":\"Line\"},{\"attributes\":{\"source\":{\"id\":\"114a354b-550f-4895-ad8e-d805f769db3d\",\"type\":\"ColumnDataSource\"}},\"id\":\"bdf43eee-e8ee-4650-80e6-e033e3445e89\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"ae2e5ad5-bfe1-49f6-86cf-75b943ff0a7f\",\"type\":\"PanTool\"},{\"attributes\":{\"axis_label\":\"Year\",\"formatter\":{\"id\":\"64dfdfd2-4149-4eee-881c-8fcdce9b7505\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"c48bb04e-017b-40c0-93b1-4d8fb19cc21c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"50793fd1-fd48-4a68-ac1e-68af34e08c9e\",\"type\":\"BasicTicker\"}},\"id\":\"a28a7ade-b65d-4ae4-b239-93e94f98669b\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"e893d050-fdf2-4d20-91b7-9952f89db74b\",\"type\":\"SaveTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"d830dcb9-e76d-4c18-9ed5-d0cc490f0c4d\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"callback\":null},\"id\":\"a92d30d2-902b-407f-93d7-9af28e485ffa\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"72572e5e-816e-491d-bf82-b7a913a51f98\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"50793fd1-fd48-4a68-ac1e-68af34e08c9e\",\"type\":\"BasicTicker\"},{\"attributes\":{\"label\":{\"value\":\"F\"},\"renderers\":[{\"id\":\"8289e9dc-0263-4b94-8b20-7f930fe0b02f\",\"type\":\"GlyphRenderer\"}]},\"id\":\"37025c84-6387-4746-af46-b3f6c26c4e58\",\"type\":\"LegendItem\"},{\"attributes\":{\"overlay\":{\"id\":\"d830dcb9-e76d-4c18-9ed5-d0cc490f0c4d\",\"type\":\"BoxAnnotation\"}},\"id\":\"5fc0a6ad-ef32-4043-8c5f-893e48faac06\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1adf8a79-1557-49f2-9772-93f8f5aede26\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"88129e5d-1b07-4d13-9542-4282e514d33d\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"3570b708-ef4a-44ac-ad4b-d81971c02f59\",\"type\":\"ResetTool\"},{\"attributes\":{\"use_scientific\":false},\"id\":\"d4d23c33-f9bb-4e94-a255-2efc6f761409\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"64dfdfd2-4149-4eee-881c-8fcdce9b7505\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"items\":[{\"id\":\"37025c84-6387-4746-af46-b3f6c26c4e58\",\"type\":\"LegendItem\"},{\"id\":\"c3309d57-d56f-4e49-a717-44d0a7a4dcf1\",\"type\":\"LegendItem\"}],\"location\":\"bottom_right\",\"plot\":{\"id\":\"c48bb04e-017b-40c0-93b1-4d8fb19cc21c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"d3a9c734-69ed-4c9c-a7d6-d33f3dcbea86\",\"type\":\"Legend\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":[90994,91955,107851,112322,129022,133056,144536,145982,178629,178367,190377,185484,212350,212907,222923,233632,237923,234199,258772,233023,299853,239349,264078,261975,275373,291636,295303,318565,334303,347210,396445,418229,557982,624399,761439,983851,1044283,1081213,1157612,1130157,1198252,1232914,1200839,1206242,1248807,1217284,1185139,1192234,1152925,1116288,1125576,1064296,1066944,1007577,1043926,1048326,1040105,1063756,1103195,1096427,1143276,1207834,1350530,1394945,1327041,1307095,1571153,1772223,1697393,1710305,1713049,1798766,1854437,1880178,1941609,1954555,2007425,2044048,2010703,2022927,2022110,2016921,1966415,1927098,1894361,1764843,1691710,1650636,1640047,1686787,1747892,1663232,1521062,1458003,1467274,1457449,1464961,1532725,1531402,1604729,1659463,1667022,1692238,1669642,1682612,1719629,1714234,1737603,1779328,1843078,1897386,1874240,1842955,1807965,1784661,1757444,1751838,1739443,1765537,1772314,1814213,1798559,1794666,1824792,1833443,1844464,1897293,1917881,1885178,1830134,1768463,1742410]}},\"id\":\"114a354b-550f-4895-ad8e-d805f769db3d\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"d9f5c24c-a539-4ef3-822b-39e342568fdd\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null},\"id\":\"636c6332-1d8f-4391-b3f2-a8aeb0c7050c\",\"type\":\"DataRange1d\"},{\"attributes\":{\"label\":{\"value\":\"M\"},\"renderers\":[{\"id\":\"5792d5ac-8797-4b28-982b-ba9b6bfdb60d\",\"type\":\"GlyphRenderer\"}]},\"id\":\"c3309d57-d56f-4e49-a717-44d0a7a4dcf1\",\"type\":\"LegendItem\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":[110492,100747,113687,104631,114445,107801,110786,101415,120855,110589,111025,101197,122039,112319,115775,117398,119572,112759,122702,106216,150532,106475,122661,119238,128129,132320,133162,146836,154344,163986,194203,225940,429924,512519,654758,848626,890110,925513,1013614,980183,1064486,1101442,1088330,1096161,1132692,1115826,1110482,1126463,1107204,1074975,1096851,1038764,1043594,990849,1032009,1040766,1036781,1066059,1108569,1106394,1158710,1227701,1380576,1426504,1362344,1345611,1623837,1827854,1752974,1771812,1790249,1877969,1943472,1968980,2037085,2057615,2113292,2155583,2120247,2133237,2132719,2121967,2068678,2031605,1992960,1861278,1783751,1744349,1738723,1789616,1859075,1768631,1622358,1558841,1572714,1561702,1569401,1643115,1641481,1721155,1782908,1789955,1813013,1790936,1802998,1846408,1839585,1865251,1912053,1999923,2052205,2019220,1995998,1959889,1930611,1902293,1892859,1883708,1909813,1918448,1961949,1940786,1939273,1972784,1982022,1993948,2051108,2070445,2034014,1976208,1909167,1880633]}},\"id\":\"f6878f06-ad9d-4045-a5b8-7c6b42de997d\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"f6878f06-ad9d-4045-a5b8-7c6b42de997d\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"a5355a89-a0ff-48e7-9d7c-c548420f30b2\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"d9f5c24c-a539-4ef3-822b-39e342568fdd\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"d1662723-5f28-464a-bf05-c3f8caafac2d\",\"type\":\"CDSView\"}},\"id\":\"5792d5ac-8797-4b28-982b-ba9b6bfdb60d\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"ae2e5ad5-bfe1-49f6-86cf-75b943ff0a7f\",\"type\":\"PanTool\"},{\"id\":\"72572e5e-816e-491d-bf82-b7a913a51f98\",\"type\":\"WheelZoomTool\"},{\"id\":\"5fc0a6ad-ef32-4043-8c5f-893e48faac06\",\"type\":\"BoxZoomTool\"},{\"id\":\"e893d050-fdf2-4d20-91b7-9952f89db74b\",\"type\":\"SaveTool\"},{\"id\":\"3570b708-ef4a-44ac-ad4b-d81971c02f59\",\"type\":\"ResetTool\"},{\"id\":\"88129e5d-1b07-4d13-9542-4282e514d33d\",\"type\":\"HelpTool\"}]},\"id\":\"ad1db200-1a4f-41cb-9764-a1bb94907eb7\",\"type\":\"Toolbar\"},{\"attributes\":{\"source\":{\"id\":\"f6878f06-ad9d-4045-a5b8-7c6b42de997d\",\"type\":\"ColumnDataSource\"}},\"id\":\"d1662723-5f28-464a-bf05-c3f8caafac2d\",\"type\":\"CDSView\"}],\"root_ids\":[\"c48bb04e-017b-40c0-93b1-4d8fb19cc21c\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.13\"}};\n",
" var render_items = [{\"docid\":\"75fb71eb-9190-43da-b46a-2389fa6ec1f6\",\"elementid\":\"2f843d7e-c92e-4e39-82fb-55f6047c5d2c\",\"modelid\":\"c48bb04e-017b-40c0-93b1-4d8fb19cc21c\"}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" clearInterval(timer);\n",
" }\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\")\n",
" clearInterval(timer);\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "c48bb04e-017b-40c0-93b1-4d8fb19cc21c"
}
},
"output_type": "display_data"
}
],
"source": [
"from bokeh.models.ranges import Range1d\n",
"totalBirths = names.pivot_table('births', index='year', columns='sex',\n",
" aggfunc=sum, margins=False)\n",
"#display(totalBirths.head())\n",
"#totalBirths[['F', 'M']][:-1].plot(title='Total births by sex and year')\n",
"fig = bk.figure(plot_width=750, plot_height=300, title=None)\n",
"fig.line(x=totalBirths.index, y=totalBirths['F'], legend='F', line_color='magenta')\n",
"fig.line(x=totalBirths.index, y=totalBirths['M'], legend='M', line_color='royalblue')\n",
"fig.legend.location = 'bottom_right'\n",
"fig.xaxis.axis_label = 'Year'\n",
"fig.yaxis.axis_label = 'Total births'\n",
"fig.yaxis[0].formatter.use_scientific = False\n",
"bk.show(fig)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 3 Splitting"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's see a couple of example about splitting data.\n",
"\n",
"In the first example we are going to view the number of births grouped by year and sex."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"year sex\n",
"1880 F 90994\n",
" M 110492\n",
"1881 F 91955\n",
" M 100747\n",
"1882 F 107851\n",
"Name: births, dtype: int64"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"names.groupby(['year', 'sex'])['births'].sum().head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The second example shows how to split the names in two groups: Boys and Girls."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" name | \n",
" sex | \n",
" births | \n",
" year | \n",
"
\n",
" \n",
" \n",
" \n",
" | 942 | \n",
" John | \n",
" M | \n",
" 9655 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1042 | \n",
" Perry | \n",
" M | \n",
" 134 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1142 | \n",
" Clayton | \n",
" M | \n",
" 60 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1242 | \n",
" Judson | \n",
" M | \n",
" 31 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1342 | \n",
" Wilmer | \n",
" M | \n",
" 19 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1442 | \n",
" Rubin | \n",
" M | \n",
" 14 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1542 | \n",
" Alois | \n",
" M | \n",
" 10 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1642 | \n",
" Fayette | \n",
" M | \n",
" 8 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1742 | \n",
" Toney | \n",
" M | \n",
" 7 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1842 | \n",
" Titus | \n",
" M | \n",
" 6 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 1942 | \n",
" Leonidas | \n",
" M | \n",
" 5 | \n",
" 1880 | \n",
"
\n",
" \n",
" | 2980 | \n",
" Tom | \n",
" M | \n",
" 349 | \n",
" 1881 | \n",
"
\n",
" \n",
" | 3080 | \n",
" Lester | \n",
" M | \n",
" 87 | \n",
" 1881 | \n",
"
\n",
" \n",
" | 3180 | \n",
" Elias | \n",
" M | \n",
" 41 | \n",
" 1881 | \n",
"
\n",
" \n",
" | 3280 | \n",
" Hans | \n",
" M | \n",
" 23 | \n",
" 1881 | \n",
"
\n",
" \n",
" | 3380 | \n",
" Aubrey | \n",
" M | \n",
" 15 | \n",
" 1881 | \n",
"
\n",
" \n",
" | 3480 | \n",
" Ford | \n",
" M | \n",
" 11 | \n",
" 1881 | \n",
"
\n",
" \n",
" | 3580 | \n",
" Rafael | \n",
" M | \n",
" 9 | \n",
" 1881 | \n",
"
\n",
" \n",
" | 3680 | \n",
" Handy | \n",
" M | \n",
" 7 | \n",
" 1881 | \n",
"
\n",
" \n",
" | 3780 | \n",
" Orla | \n",
" M | \n",
" 6 | \n",
" 1881 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" name sex births year\n",
"942 John M 9655 1880\n",
"1042 Perry M 134 1880\n",
"1142 Clayton M 60 1880\n",
"1242 Judson M 31 1880\n",
"1342 Wilmer M 19 1880\n",
"1442 Rubin M 14 1880\n",
"1542 Alois M 10 1880\n",
"1642 Fayette M 8 1880\n",
"1742 Toney M 7 1880\n",
"1842 Titus M 6 1880\n",
"1942 Leonidas M 5 1880\n",
"2980 Tom M 349 1881\n",
"3080 Lester M 87 1881\n",
"3180 Elias M 41 1881\n",
"3280 Hans M 23 1881\n",
"3380 Aubrey M 15 1881\n",
"3480 Ford M 11 1881\n",
"3580 Rafael M 9 1881\n",
"3680 Handy M 7 1881\n",
"3780 Orla M 6 1881"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"boys = names[names.sex == 'M']\n",
"girls = names[names.sex == 'F']\n",
"display(boys[:2000:100])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can see how many boys with a specific name were born each year."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" name | \n",
" sex | \n",
" births | \n",
" year | \n",
"
\n",
" \n",
" \n",
" \n",
" | 824344 | \n",
" Jayden | \n",
" M | \n",
" 7 | \n",
" 1977 | \n",
"
\n",
" \n",
" | 843205 | \n",
" Jayden | \n",
" M | \n",
" 6 | \n",
" 1978 | \n",
"
\n",
" \n",
" | 899512 | \n",
" Jayden | \n",
" M | \n",
" 9 | \n",
" 1981 | \n",
"
\n",
" \n",
" | 940021 | \n",
" Jayden | \n",
" M | \n",
" 6 | \n",
" 1983 | \n",
"
\n",
" \n",
" | 960469 | \n",
" Jayden | \n",
" M | \n",
" 5 | \n",
" 1984 | \n",
"
\n",
" \n",
" | 977725 | \n",
" Jayden | \n",
" M | \n",
" 10 | \n",
" 1985 | \n",
"
\n",
" \n",
" | 997266 | \n",
" Jayden | \n",
" M | \n",
" 14 | \n",
" 1986 | \n",
"
\n",
" \n",
" | 1019074 | \n",
" Jayden | \n",
" M | \n",
" 11 | \n",
" 1987 | \n",
"
\n",
" \n",
" | 1040265 | \n",
" Jayden | \n",
" M | \n",
" 16 | \n",
" 1988 | \n",
"
\n",
" \n",
" | 1062845 | \n",
" Jayden | \n",
" M | \n",
" 22 | \n",
" 1989 | \n",
"
\n",
" \n",
" | 1087121 | \n",
" Jayden | \n",
" M | \n",
" 25 | \n",
" 1990 | \n",
"
\n",
" \n",
" | 1111407 | \n",
" Jayden | \n",
" M | \n",
" 38 | \n",
" 1991 | \n",
"
\n",
" \n",
" | 1136484 | \n",
" Jayden | \n",
" M | \n",
" 45 | \n",
" 1992 | \n",
"
\n",
" \n",
" | 1161561 | \n",
" Jayden | \n",
" M | \n",
" 77 | \n",
" 1993 | \n",
"
\n",
" \n",
" | 1187019 | \n",
" Jayden | \n",
" M | \n",
" 159 | \n",
" 1994 | \n",
"
\n",
" \n",
" | 1212851 | \n",
" Jayden | \n",
" M | \n",
" 239 | \n",
" 1995 | \n",
"
\n",
" \n",
" | 1238981 | \n",
" Jayden | \n",
" M | \n",
" 294 | \n",
" 1996 | \n",
"
\n",
" \n",
" | 1265586 | \n",
" Jayden | \n",
" M | \n",
" 387 | \n",
" 1997 | \n",
"
\n",
" \n",
" | 1292859 | \n",
" Jayden | \n",
" M | \n",
" 620 | \n",
" 1998 | \n",
"
\n",
" \n",
" | 1320950 | \n",
" Jayden | \n",
" M | \n",
" 1230 | \n",
" 1999 | \n",
"
\n",
" \n",
" | 1350145 | \n",
" Jayden | \n",
" M | \n",
" 1821 | \n",
" 2000 | \n",
"
\n",
" \n",
" | 1380163 | \n",
" Jayden | \n",
" M | \n",
" 2833 | \n",
" 2001 | \n",
"
\n",
" \n",
" | 1410493 | \n",
" Jayden | \n",
" M | \n",
" 3853 | \n",
" 2002 | \n",
"
\n",
" \n",
" | 1441364 | \n",
" Jayden | \n",
" M | \n",
" 5542 | \n",
" 2003 | \n",
"
\n",
" \n",
" | 1472909 | \n",
" Jayden | \n",
" M | \n",
" 6920 | \n",
" 2004 | \n",
"
\n",
" \n",
" | 1505279 | \n",
" Jayden | \n",
" M | \n",
" 8244 | \n",
" 2005 | \n",
"
\n",
" \n",
" | 1538659 | \n",
" Jayden | \n",
" M | \n",
" 9610 | \n",
" 2006 | \n",
"
\n",
" \n",
" | 1573173 | \n",
" Jayden | \n",
" M | \n",
" 15206 | \n",
" 2007 | \n",
"
\n",
" \n",
" | 1607962 | \n",
" Jayden | \n",
" M | \n",
" 17105 | \n",
" 2008 | \n",
"
\n",
" \n",
" | 1642694 | \n",
" Jayden | \n",
" M | \n",
" 17217 | \n",
" 2009 | \n",
"
\n",
" \n",
" | 1676954 | \n",
" Jayden | \n",
" M | \n",
" 17101 | \n",
" 2010 | \n",
"
\n",
" \n",
" | 1710637 | \n",
" Jayden | \n",
" M | \n",
" 16861 | \n",
" 2011 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" name sex births year\n",
"824344 Jayden M 7 1977\n",
"843205 Jayden M 6 1978\n",
"899512 Jayden M 9 1981\n",
"940021 Jayden M 6 1983\n",
"960469 Jayden M 5 1984\n",
"977725 Jayden M 10 1985\n",
"997266 Jayden M 14 1986\n",
"1019074 Jayden M 11 1987\n",
"1040265 Jayden M 16 1988\n",
"1062845 Jayden M 22 1989\n",
"1087121 Jayden M 25 1990\n",
"1111407 Jayden M 38 1991\n",
"1136484 Jayden M 45 1992\n",
"1161561 Jayden M 77 1993\n",
"1187019 Jayden M 159 1994\n",
"1212851 Jayden M 239 1995\n",
"1238981 Jayden M 294 1996\n",
"1265586 Jayden M 387 1997\n",
"1292859 Jayden M 620 1998\n",
"1320950 Jayden M 1230 1999\n",
"1350145 Jayden M 1821 2000\n",
"1380163 Jayden M 2833 2001\n",
"1410493 Jayden M 3853 2002\n",
"1441364 Jayden M 5542 2003\n",
"1472909 Jayden M 6920 2004\n",
"1505279 Jayden M 8244 2005\n",
"1538659 Jayden M 9610 2006\n",
"1573173 Jayden M 15206 2007\n",
"1607962 Jayden M 17105 2008\n",
"1642694 Jayden M 17217 2009\n",
"1676954 Jayden M 17101 2010\n",
"1710637 Jayden M 16861 2011"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"boys[boys['name']=='Jayden']"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"d64242e8-c5e8-47b6-9a17-2cd2f6fd3c08\":{\"roots\":{\"references\":[{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":{\"__ndarray__\":\"AAAAAACQfEAAAAAAABB+QAAAAAAAWIFAAAAAAADAfUAAAAAAAKiAQAAAAAAAwH5AAAAAAAA4gEAAAAAAAPB8QAAAAAAA+IJAAAAAAABgfkAAAAAAAJB+QAAAAAAAIHpAAAAAAAA4gUAAAAAAABB+QAAAAAAAsH9AAAAAAABwfkAAAAAAADCAQAAAAAAA4H1AAAAAAAD4gEAAAAAAAFB9QAAAAAAAqIlAAAAAAADwfUAAAAAAAHiBQAAAAAAAQIFAAAAAAADYgkAAAAAAAGCDQAAAAAAAQIFAAAAAAAC4g0AAAAAAACCEQAAAAAAA4IVAAAAAAADAi0AAAAAAAACNQAAAAAAAtJRAAAAAAADcl0AAAAAAAFydQAAAAAAARKJAAAAAAAAUokAAAAAAACyjQAAAAAAAlqNAAAAAAACiokAAAAAAANahQAAAAAAAdqJAAAAAAABaokAAAAAAAD6hQAAAAAAAiqBAAAAAAABaoEAAAAAAAMyfQAAAAAAAsJ1AAAAAAABwm0AAAAAAAACbQAAAAAAAGJpAAAAAAADElkAAAAAAAKiWQAAAAAAAEJVAAAAAAACwlEAAAAAAAESVQAAAAAAAWJNAAAAAAAD8kkAAAAAAABSSQAAAAAAAiJFAAAAAAADwkUAAAAAAAKCSQAAAAAAA+JNAAAAAAACglEAAAAAAAPiSQAAAAAAAxJFAAAAAAABclEAAAAAAABCWQAAAAAAAYJNAAAAAAAA8kUAAAAAAAOCNQAAAAAAAHJBAAAAAAABojUAAAAAAAJCLQAAAAAAAWItAAAAAAAA4i0AAAAAAAMCNQAAAAAAAuJBAAAAAAABgkkAAAAAAAECUQAAAAAAA6JJAAAAAAACwkkAAAAAAAKiQQAAAAAAA0I9AAAAAAADYjUAAAAAAADCIQAAAAAAAKIVAAAAAAAAog0AAAAAAAKiBQAAAAAAAQIJAAAAAAADIgkAAAAAAAOiAQAAAAAAAEH9AAAAAAADgfUAAAAAAAEB7QAAAAAAAUHpAAAAAAADgeEAAAAAAAEB2QAAAAAAA8HlAAAAAAACAd0AAAAAAAOB2QAAAAAAA4HdAAAAAAABQd0AAAAAAAHB2QAAAAAAAsHZAAAAAAACwdUAAAAAAAMB3QAAAAAAAAH5AAAAAAADwfUAAAAAAAHB/QAAAAAAAQIJAAAAAAABwgkAAAAAAAPCBQAAAAAAAkIFAAAAAAABIgUAAAAAAAMCBQAAAAAAAcIBAAAAAAAAgfkAAAAAAAJB+QAAAAAAAAH9AAAAAAAAAgEAAAAAAADiBQAAAAAAAcIFAAAAAAAAAgkAAAAAAAIiCQAAAAAAAWIFAAAAAAABAgkAAAAAAACCDQAAAAAAA4IJAAAAAAAAggkAAAAAAABiBQAAAAAAA6IBA\",\"dtype\":\"float64\",\"shape\":[132]}}},\"id\":\"2489db6e-0b76-405f-8210-7ba81715d3ff\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"a6bbbf58-dae5-4e3b-8e8d-8f5166dde96c\",\"type\":\"Line\"},{\"attributes\":{\"data_source\":{\"id\":\"c47e3267-6b74-4187-bded-8c065584356c\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"5be17c9d-cdc2-49d0-805c-15209541fcf5\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"463cda52-9ed1-4f20-8275-0b34d03e0866\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"85006748-2c63-4edc-b8fd-0452f2b13e1f\",\"type\":\"CDSView\"}},\"id\":\"3b8f1241-1f5e-4678-8102-683cf1fbdea9\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"f80471cb-1daf-4d56-a348-b3f5b7824011\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"e1070c8d-921c-4bc8-97a5-2f568f1f6044\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"b39d5651-de00-490c-a10e-0b7dda6cfdd6\",\"type\":\"PanTool\"},{\"attributes\":{\"label\":{\"value\":\"Sam\"},\"renderers\":[{\"id\":\"7a952bad-6602-48bc-b77a-3a01d0fe4086\",\"type\":\"GlyphRenderer\"}]},\"id\":\"5c64d32e-589f-41d5-b4e3-848f8cdd0e57\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"ee2e69ce-ca7a-4715-934d-bf5a1be636e0\",\"type\":\"BasicTicker\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"ac8c2821-bad4-4b8f-8180-342b7ce8add9\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"callback\":null},\"id\":\"a9f5a590-ba43-4bdb-8548-ef11cdacdf77\",\"type\":\"DataRange1d\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"4fb809e7-e85c-44ad-8377-f6d2202388dd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"ee2e69ce-ca7a-4715-934d-bf5a1be636e0\",\"type\":\"BasicTicker\"}},\"id\":\"6259ae44-4bd7-41c6-b6f1-2d737a59c0ca\",\"type\":\"Grid\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"66463383-4687-4a77-81c4-9c888247fc69\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"items\":[{\"id\":\"5c64d32e-589f-41d5-b4e3-848f8cdd0e57\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"1d6b9143-f600-45d6-b4fd-8817979e9d2b\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"1f5ea08b-a4f7-4424-83b4-ae154a1607de\",\"type\":\"Legend\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"52a898a0-ab93-4d4a-8542-fddf314de217\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"e001c5ec-f5d4-4fe7-82d2-8a7d8ed6fc83\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"63e61014-34b2-4db7-a633-1e0f723a0ac4\",\"type\":\"PanTool\"},{\"id\":\"4ecdfc8f-878d-4b13-a06f-5dbe977624f2\",\"type\":\"WheelZoomTool\"},{\"id\":\"5048f2cb-9060-4c79-a45e-2bff7a44ab41\",\"type\":\"BoxZoomTool\"},{\"id\":\"0f4a6a1f-f987-450c-bc85-df66cee9d166\",\"type\":\"SaveTool\"},{\"id\":\"8445beba-06cc-4fd1-b647-4ddfece2571a\",\"type\":\"ResetTool\"},{\"id\":\"0ab52112-dc05-40a5-8f01-4fc485711089\",\"type\":\"HelpTool\"}]},\"id\":\"98ad6e85-de39-483d-b85d-9d582a046d6e\",\"type\":\"Toolbar\"},{\"attributes\":{\"label\":{\"value\":\"Bob\"},\"renderers\":[{\"id\":\"d2dc96c5-37bd-4eaf-9990-bcfb8cfef5fd\",\"type\":\"GlyphRenderer\"}]},\"id\":\"a25ff9c2-4b49-46e9-a2b3-6fe94f166072\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"15fe67b2-36c4-48ff-a128-64798243aaf8\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"b5a41966-8acf-4e9d-9740-18b3e9fdec18\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"c8b4a879-6a0f-410a-9bf5-75daea8b2d64\",\"type\":\"BasicTicker\"}},\"id\":\"460beb89-9e86-43ea-a7af-2717f9d36d73\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":{\"__ndarray__\":\"AAAAAAAAR0AAAAAAAABJQAAAAAAAgE1AAAAAAAAAT0AAAAAAAABJQAAAAAAAAEpAAAAAAACAUEAAAAAAAIBSQAAAAAAAgE1AAAAAAAAASkAAAAAAAIBKQAAAAAAAgEtAAAAAAACATkAAAAAAAIBNQAAAAAAAAEhAAAAAAAAAS0AAAAAAAIBGQAAAAAAAgEpAAAAAAACATkAAAAAAAIBNQAAAAAAAgFhAAAAAAACASEAAAAAAAABQQAAAAAAAgFBAAAAAAABAUEAAAAAAAABNQAAAAAAAQFFAAAAAAABAU0AAAAAAAEBTQAAAAAAAAE1AAAAAAADAWUAAAAAAAABTQAAAAAAAoGFAAAAAAACAZEAAAAAAACBrQAAAAAAAgHJAAAAAAAAAc0AAAAAAAAB2QAAAAAAA0H1AAAAAAAAggUAAAAAAADCGQAAAAAAA6IhAAAAAAACgiEAAAAAAAKiMQAAAAAAAPJJAAAAAAABYlUAAAAAAAMybQAAAAAAA0J5AAAAAAABYoEAAAAAAAG6gQAAAAAAAgKFAAAAAAAAcokAAAAAAAPaiQAAAAAAAUqFAAAAAAABco0AAAAAAAKiiQAAAAAAA0KJAAAAAAAB2okAAAAAAADihQAAAAAAAhKFAAAAAAABEoEAAAAAAADKgQAAAAAAANqFAAAAAAADEoUAAAAAAAKigQAAAAAAA+qBAAAAAAAB8o0AAAAAAAKKjQAAAAAAAoJ5AAAAAAADklkAAAAAAAHiOQAAAAAAASIlAAAAAAACAh0AAAAAAALiFQAAAAAAAwIVAAAAAAADgiEAAAAAAANCPQAAAAAAAWJxAAAAAAACuo0AAAAAAABCmQAAAAAAAQKVAAAAAAACKo0AAAAAAAOqgQAAAAAAA2JxAAAAAAABklkAAAAAAAECPQAAAAAAAYIVAAAAAAACogEAAAAAAAOB9QAAAAAAAoHpAAAAAAABQeUAAAAAAAFB0QAAAAAAAgGtAAAAAAAAAakAAAAAAAEBlQAAAAAAAAGVAAAAAAABAYUAAAAAAAABeQAAAAAAAgFtAAAAAAACAXUAAAAAAAMBaQAAAAAAAAFVAAAAAAADAVkAAAAAAAEBWQAAAAAAAQFNAAAAAAABAUkAAAAAAAABPQAAAAAAAAExAAAAAAACATEAAAAAAAABMQAAAAAAAgEpAAAAAAACAUEAAAAAAAABFQAAAAAAAAENAAAAAAACAQkAAAAAAAAA+QAAAAAAAAD9AAAAAAACAQEAAAAAAAAA1QAAAAAAAADBAAAAAAAAAP0AAAAAAAAAzQAAAAAAAADFAAAAAAAAAIkAAAAAAAAAyQAAAAAAAADhAAAAAAAAAJkAAAAAAAAAgQAAAAAAAADdAAAAAAAAANkAAAAAAAAAkQAAAAAAAACxA\",\"dtype\":\"float64\",\"shape\":[132]}}},\"id\":\"f9300199-f862-4170-b204-987eb79b3270\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"overlay\":{\"id\":\"66463383-4687-4a77-81c4-9c888247fc69\",\"type\":\"BoxAnnotation\"}},\"id\":\"8de504ae-fe0e-4f3e-a93c-242c23933abb\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"below\":[{\"id\":\"a03e95f3-4d2e-48f1-8ac4-6f4a91237fa2\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"9605a406-094b-43e8-a0b8-cacf12878783\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"plot_width\":700,\"renderers\":[{\"id\":\"a03e95f3-4d2e-48f1-8ac4-6f4a91237fa2\",\"type\":\"LinearAxis\"},{\"id\":\"460beb89-9e86-43ea-a7af-2717f9d36d73\",\"type\":\"Grid\"},{\"id\":\"9605a406-094b-43e8-a0b8-cacf12878783\",\"type\":\"LinearAxis\"},{\"id\":\"284b9a77-b9b3-4a2e-b323-f1328e27a58e\",\"type\":\"Grid\"},{\"id\":\"63e17c1b-cedc-4427-bc87-ff10cc2f06b3\",\"type\":\"BoxAnnotation\"},{\"id\":\"81703e83-84bb-466c-80fe-54c70d520392\",\"type\":\"Legend\"},{\"id\":\"40f07397-df50-4b49-84f7-5f981c8b9809\",\"type\":\"GlyphRenderer\"}],\"title\":null,\"toolbar\":{\"id\":\"98ad6e85-de39-483d-b85d-9d582a046d6e\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"a9f5a590-ba43-4bdb-8548-ef11cdacdf77\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"98bed23e-54b9-49cf-ab1a-8f857c70f41b\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"ed918acf-6d03-4802-87cd-7f2b48491f7d\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"c3284b29-d45f-458e-a3c6-c3cf5f668c84\",\"type\":\"LinearScale\"}},\"id\":\"b5a41966-8acf-4e9d-9740-18b3e9fdec18\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"0eec9790-d453-4234-b54a-b955b07fd96d\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"634dd819-5654-42c9-8ff4-8f7c50e9a3a4\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"2cda92ea-3cc7-430d-8632-30be536b3d7d\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"c3284b29-d45f-458e-a3c6-c3cf5f668c84\",\"type\":\"LinearScale\"},{\"attributes\":{\"data_source\":{\"id\":\"f9300199-f862-4170-b204-987eb79b3270\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"e1070c8d-921c-4bc8-97a5-2f568f1f6044\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"52a898a0-ab93-4d4a-8542-fddf314de217\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"734d8f2a-22db-49be-877e-5e0a4245944c\",\"type\":\"CDSView\"}},\"id\":\"d2dc96c5-37bd-4eaf-9990-bcfb8cfef5fd\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"c559db37-9df1-4219-abdb-03940de83bc3\",\"type\":\"Line\"},{\"attributes\":{\"overlay\":{\"id\":\"6e0ecfcd-8a20-4eac-896b-fd5ae0fbe391\",\"type\":\"BoxAnnotation\"}},\"id\":\"a61f06eb-bbc2-4362-b77d-cecc627c57a8\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"ff4de11a-e3a3-4cea-8a11-f20609b33479\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"label\":{\"value\":\"John\"},\"renderers\":[{\"id\":\"40f07397-df50-4b49-84f7-5f981c8b9809\",\"type\":\"GlyphRenderer\"}]},\"id\":\"12ace5cd-ceec-4036-9eb1-88d11da934f4\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"4c78a652-988c-4d2e-82f0-47452691a3c5\",\"type\":\"HelpTool\"},{\"attributes\":{\"overlay\":{\"id\":\"0eec9790-d453-4234-b54a-b955b07fd96d\",\"type\":\"BoxAnnotation\"}},\"id\":\"96104903-69e1-4a63-9be3-26fecb0eb35f\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"98bed23e-54b9-49cf-ab1a-8f857c70f41b\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"60b88684-9c2a-466b-ad59-89c188a43823\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"95bfe4b9-2791-4ed2-b843-516c3df28dd6\",\"type\":\"SaveTool\"},{\"attributes\":{\"callback\":null},\"id\":\"ed918acf-6d03-4802-87cd-7f2b48491f7d\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"b9f39a6b-e5db-4c46-ac88-254b58e1ba8b\",\"type\":\"ResetTool\"},{\"attributes\":{\"formatter\":{\"id\":\"a4f0ace5-4250-4482-a0ac-83f49093ce9d\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"b5a41966-8acf-4e9d-9740-18b3e9fdec18\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"c8b4a879-6a0f-410a-9bf5-75daea8b2d64\",\"type\":\"BasicTicker\"}},\"id\":\"a03e95f3-4d2e-48f1-8ac4-6f4a91237fa2\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"8beeba60-bce1-4628-81ee-23fd0e5a5301\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"2d3fbe6c-390c-426c-9d8c-d32087d6acb6\",\"type\":\"HelpTool\"},{\"attributes\":{\"source\":{\"id\":\"2489db6e-0b76-405f-8210-7ba81715d3ff\",\"type\":\"ColumnDataSource\"}},\"id\":\"9ec74890-05ee-4de9-92de-b7f7e14743a3\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"c8b4a879-6a0f-410a-9bf5-75daea8b2d64\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"0ffb9c5c-6232-4fde-bfff-83a3e155889b\",\"type\":\"ResetTool\"},{\"attributes\":{\"formatter\":{\"id\":\"66cd2e9b-62d9-408d-8cf5-17d1963a82b3\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"b5a41966-8acf-4e9d-9740-18b3e9fdec18\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"e6ae9e8d-24cc-4207-ad6b-de3296572d5c\",\"type\":\"BasicTicker\"}},\"id\":\"9605a406-094b-43e8-a0b8-cacf12878783\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"6c9e4767-8202-497a-a379-c4169e8d0fb0\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"e6ae9e8d-24cc-4207-ad6b-de3296572d5c\",\"type\":\"BasicTicker\"},{\"attributes\":{\"source\":{\"id\":\"f9300199-f862-4170-b204-987eb79b3270\",\"type\":\"ColumnDataSource\"}},\"id\":\"734d8f2a-22db-49be-877e-5e0a4245944c\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"e97122f8-41d9-455b-9711-09bb1ee21672\",\"type\":\"LinearScale\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"b5a41966-8acf-4e9d-9740-18b3e9fdec18\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"e6ae9e8d-24cc-4207-ad6b-de3296572d5c\",\"type\":\"BasicTicker\"}},\"id\":\"284b9a77-b9b3-4a2e-b323-f1328e27a58e\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"111efeda-f619-4c81-a95e-6cfef28cf2c2\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"tools\":[{\"id\":\"634dd819-5654-42c9-8ff4-8f7c50e9a3a4\",\"type\":\"PanTool\"},{\"id\":\"e001c5ec-f5d4-4fe7-82d2-8a7d8ed6fc83\",\"type\":\"WheelZoomTool\"},{\"id\":\"8de504ae-fe0e-4f3e-a93c-242c23933abb\",\"type\":\"BoxZoomTool\"},{\"id\":\"4e402708-1f02-49a4-963e-ba83daf9e8c1\",\"type\":\"SaveTool\"},{\"id\":\"91e6fff1-f0c3-461b-bc57-e64d4c7bf24f\",\"type\":\"ResetTool\"},{\"id\":\"352a30c9-3f9b-428d-9cc7-8fc0946cb403\",\"type\":\"HelpTool\"},{\"id\":\"b39d5651-de00-490c-a10e-0b7dda6cfdd6\",\"type\":\"PanTool\"},{\"id\":\"29ce51b4-92fb-49c5-a05d-fc2bc39451f2\",\"type\":\"WheelZoomTool\"},{\"id\":\"3565a083-99df-4e3a-8061-0010d771b691\",\"type\":\"BoxZoomTool\"},{\"id\":\"8f5bf34b-b828-4bb9-adc8-af9a885de897\",\"type\":\"SaveTool\"},{\"id\":\"95c78650-54c6-485b-a67b-0dfbd79ea28b\",\"type\":\"ResetTool\"},{\"id\":\"117a43a8-0d7e-4210-bc42-164aad59017b\",\"type\":\"HelpTool\"},{\"id\":\"8d0dd804-0347-47a6-9db6-5285d6fb39ad\",\"type\":\"PanTool\"},{\"id\":\"15fe67b2-36c4-48ff-a128-64798243aaf8\",\"type\":\"WheelZoomTool\"},{\"id\":\"a61f06eb-bbc2-4362-b77d-cecc627c57a8\",\"type\":\"BoxZoomTool\"},{\"id\":\"60b88684-9c2a-466b-ad59-89c188a43823\",\"type\":\"SaveTool\"},{\"id\":\"0ffb9c5c-6232-4fde-bfff-83a3e155889b\",\"type\":\"ResetTool\"},{\"id\":\"4c78a652-988c-4d2e-82f0-47452691a3c5\",\"type\":\"HelpTool\"},{\"id\":\"63e61014-34b2-4db7-a633-1e0f723a0ac4\",\"type\":\"PanTool\"},{\"id\":\"4ecdfc8f-878d-4b13-a06f-5dbe977624f2\",\"type\":\"WheelZoomTool\"},{\"id\":\"5048f2cb-9060-4c79-a45e-2bff7a44ab41\",\"type\":\"BoxZoomTool\"},{\"id\":\"0f4a6a1f-f987-450c-bc85-df66cee9d166\",\"type\":\"SaveTool\"},{\"id\":\"8445beba-06cc-4fd1-b647-4ddfece2571a\",\"type\":\"ResetTool\"},{\"id\":\"0ab52112-dc05-40a5-8f01-4fc485711089\",\"type\":\"HelpTool\"},{\"id\":\"0d5f13de-24ea-409d-86b5-4f1d035b3c71\",\"type\":\"PanTool\"},{\"id\":\"8eca0026-d74d-419c-8811-eb7018eb6a83\",\"type\":\"WheelZoomTool\"},{\"id\":\"438a5f1a-d467-4535-9709-764faa27ac46\",\"type\":\"BoxZoomTool\"},{\"id\":\"99093f1b-d2e5-4dcb-829e-416e9ed4e96e\",\"type\":\"SaveTool\"},{\"id\":\"7f6dd83a-c0fa-4d2f-800f-ac7c741fd929\",\"type\":\"ResetTool\"},{\"id\":\"64d226e4-b0af-4571-a7d5-977b756ae1c9\",\"type\":\"HelpTool\"},{\"id\":\"2cda92ea-3cc7-430d-8632-30be536b3d7d\",\"type\":\"PanTool\"},{\"id\":\"ff4de11a-e3a3-4cea-8a11-f20609b33479\",\"type\":\"WheelZoomTool\"},{\"id\":\"96104903-69e1-4a63-9be3-26fecb0eb35f\",\"type\":\"BoxZoomTool\"},{\"id\":\"95bfe4b9-2791-4ed2-b843-516c3df28dd6\",\"type\":\"SaveTool\"},{\"id\":\"b9f39a6b-e5db-4c46-ac88-254b58e1ba8b\",\"type\":\"ResetTool\"},{\"id\":\"2d3fbe6c-390c-426c-9d8c-d32087d6acb6\",\"type\":\"HelpTool\"}]},\"id\":\"b5a84323-6f4d-4a35-8607-475ebea1a28b\",\"type\":\"ProxyToolbar\"},{\"attributes\":{\"callback\":null},\"id\":\"875d1a97-1f7f-4661-b5d7-08154c689f39\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":{\"id\":\"d6274d50-855b-45a1-8e52-40533a11f671\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"34a45fdb-2e4e-41f0-b5f1-abeebcbf03be\",\"type\":\"BasicTicker\"}},\"id\":\"8f6854d1-7fbf-4213-a376-a5407931106a\",\"type\":\"Grid\"},{\"attributes\":{\"children\":[{\"id\":\"b5a41966-8acf-4e9d-9740-18b3e9fdec18\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"bfe5c944-a609-49ba-b95a-59e282e16a02\",\"type\":\"Row\"},{\"attributes\":{\"data_source\":{\"id\":\"2bc40f88-f258-4ac3-8459-c8db26f87be6\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"d2e4d680-ad92-4502-b87e-9aff28819c76\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"4abd3503-3d51-487a-abeb-630da9a52fca\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"827c2ea2-1e5c-44e6-a253-af5f5156bece\",\"type\":\"CDSView\"}},\"id\":\"8c345eb4-75a1-4743-9e40-86ce644c87d5\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"7a8ce3f9-a52b-48cd-b870-7b524ec5e724\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":{\"__ndarray__\":\"AAAAAIDbwkAAAAAAgCDBQAAAAACAqsJAAAAAAABfwUAAAAAAgFXCQAAAAAAAGsFAAAAAAAChwUAAAAAAAK6/QAAAAAAAEMJAAAAAAACywEAAAAAAAJvAQAAAAAAAAb5AAAAAAICnwUAAAAAAAHG/QAAAAAAAF8BAAAAAAIBAwEAAAAAAAMu/QAAAAAAAfr1AAAAAAADgv0AAAAAAAE67QAAAAAAANMNAAAAAAADzukAAAAAAAOS+QAAAAAAAub1AAAAAAACsv0AAAAAAAHu/QAAAAAAAJMBAAAAAAICLwUAAAAAAAD/CQAAAAACAu8JAAAAAAIBdxkAAAAAAgELKQAAAAAAAAthAAAAAAACj3EAAAAAAIIfiQAAAAADAOudAAAAAAMBv6EAAAAAAgFHpQAAAAAAgnutAAAAAACAj6kAAAAAAoMrrQAAAAAAAbuxAAAAAAOD260AAAAAA4BDsQAAAAADA1uxAAAAAAADr60AAAAAA4GTrQAAAAACgUetAAAAAACA96kAAAAAAgG7pQAAAAAAAl+lAAAAAAKCh50AAAAAAYLnnQAAAAABgj+ZAAAAAAKDP5kAAAAAAIDDnQAAAAABgROdAAAAAAEDL50AAAAAAoKfoQAAAAADg6ehAAAAAAOC86kAAAAAAIBPsQAAAAABQHvBAAAAAADDS8EAAAAAAUELwQAAAAADQJPBAAAAAACBa80AAAAAAEI31QAAAAAAQMvRAAAAAAGDL80AAAAAAQGLzQAAAAAAQ3/NAAAAAANBI9EAAAAAA4IrzQAAAAAAQzfNAAAAAAICJ80AAAAAAALbzQAAAAACAR/NAAAAAAACM8kAAAAAA4KfyQAAAAADglfJAAAAAAFCB80AAAAAA0CbzQAAAAACgMvNAAAAAAIAm9EAAAAAAkHjxQAAAAAAAw+9AAAAAAOAX7kAAAAAAgL7tQAAAAADgtOxAAAAAAICU7EAAAAAAICbpQAAAAACgFOVAAAAAAOAg40AAAAAA4GHiQAAAAACAIuFAAAAAAMCY4EAAAAAA4LXgQAAAAABgm+BAAAAAAEBL4UAAAAAAADbhQAAAAACABeFAAAAAAMDu4EAAAAAAQC7gQAAAAABA0d9AAAAAAEC/3kAAAAAAwHfdQAAAAACA1dxAAAAAAECx3EAAAAAAQCLdQAAAAACAYtxAAAAAAMAi20AAAAAAgJzZQAAAAABAZNhAAAAAAACb10AAAAAAgKvWQAAAAABAodVAAAAAAIDd1EAAAAAAQB3UQAAAAACA2tNAAAAAAECZ00AAAAAAwG7SQAAAAADABdFAAAAAAIDO0EAAAAAAwAvQQAAAAAAAxc5AAAAAAICTzUAAAAAAgCTMQAAAAAAA9clAAAAAAACUx0AAAAAAAHbGQAAAAAAAW8VA\",\"dtype\":\"float64\",\"shape\":[132]}}},\"id\":\"22a266c3-c342-445f-9aa9-7fe0e70ead9f\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"352a30c9-3f9b-428d-9cc7-8fc0946cb403\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"47f61ad4-652e-4662-bd56-94a51ddae90f\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"91e6fff1-f0c3-461b-bc57-e64d4c7bf24f\",\"type\":\"ResetTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"63e17c1b-cedc-4427-bc87-ff10cc2f06b3\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"items\":[{\"id\":\"a25ff9c2-4b49-46e9-a2b3-6fe94f166072\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"4fb809e7-e85c-44ad-8377-f6d2202388dd\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"86a07eeb-79fe-4195-a7c5-746949084fb6\",\"type\":\"Legend\"},{\"attributes\":{\"overlay\":{\"id\":\"ac8c2821-bad4-4b8f-8180-342b7ce8add9\",\"type\":\"BoxAnnotation\"}},\"id\":\"3565a083-99df-4e3a-8061-0010d771b691\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"63e61014-34b2-4db7-a633-1e0f723a0ac4\",\"type\":\"PanTool\"},{\"attributes\":{\"toolbar\":{\"id\":\"b5a84323-6f4d-4a35-8607-475ebea1a28b\",\"type\":\"ProxyToolbar\"},\"toolbar_location\":\"above\"},\"id\":\"c7fbca12-cc89-4512-9c64-5305c23a4de1\",\"type\":\"ToolbarBox\"},{\"attributes\":{\"data_source\":{\"id\":\"22a266c3-c342-445f-9aa9-7fe0e70ead9f\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"7a8ce3f9-a52b-48cd-b870-7b524ec5e724\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"c559db37-9df1-4219-abdb-03940de83bc3\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"738d1d5f-35c0-4dcf-bce2-c525603af9c4\",\"type\":\"CDSView\"}},\"id\":\"40f07397-df50-4b49-84f7-5f981c8b9809\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"281b3c18-92c3-45be-b694-c3b6890f0d7f\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"children\":[{\"id\":\"89921bbc-98fa-4eaf-9a47-83661fe1eda1\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"75e904ff-6b23-4568-aa5d-521ece598627\",\"type\":\"Row\"},{\"attributes\":{},\"id\":\"4ecdfc8f-878d-4b13-a06f-5dbe977624f2\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":{\"__ndarray__\":\"AAAAAAAA+H8AAAAAAAAgQAAAAAAAAPh/AAAAAAAA+H8AAAAAAAD4fwAAAAAAAPh/AAAAAAAAHEAAAAAAAAAUQAAAAAAAAPh/AAAAAAAAFEAAAAAAAAD4fwAAAAAAAPh/AAAAAAAAHEAAAAAAAAAcQAAAAAAAAPh/AAAAAAAAFEAAAAAAAAD4fwAAAAAAACBAAAAAAAAAIkAAAAAAAAAmQAAAAAAAACBAAAAAAAAAHEAAAAAAAAAoQAAAAAAAAPh/AAAAAAAAIEAAAAAAAAAoQAAAAAAAACJAAAAAAAAAJEAAAAAAAAAgQAAAAAAAAChAAAAAAAAAMkAAAAAAAAAuQAAAAAAAgEVAAAAAAAAAPUAAAAAAAABIQAAAAAAAgFBAAAAAAACATkAAAAAAAEBRQAAAAAAAAFdAAAAAAACAWkAAAAAAAIBSQAAAAAAAQFVAAAAAAADAWkAAAAAAAABZQAAAAAAAQFBAAAAAAADAUkAAAAAAAEBWQAAAAAAAAFBAAAAAAADAV0AAAAAAAEBUQAAAAAAAAFRAAAAAAACATkAAAAAAAABMQAAAAAAAAExAAAAAAACAUkAAAAAAAIBIQAAAAAAAAE1AAAAAAACASEAAAAAAAABLQAAAAAAAQFFAAAAAAABAU0AAAAAAAABLQAAAAAAAgEtAAAAAAAAATkAAAAAAAABMQAAAAAAAgEhAAAAAAACAS0AAAAAAAIBQQAAAAAAAgERAAAAAAACASUAAAAAAAABQQAAAAAAAgEZAAAAAAAAAS0AAAAAAAABBQAAAAAAAgEdAAAAAAADAUEAAAAAAAGB6QAAAAAAAoIJAAAAAAABAd0AAAAAAAJBwQAAAAAAAQG5AAAAAAACAZ0AAAAAAAEBlQAAAAAAAQGFAAAAAAABAYEAAAAAAAKBjQAAAAAAAgF1AAAAAAADgZEAAAAAAAGBhQAAAAAAAgGJAAAAAAABgYEAAAAAAAEBgQAAAAAAAwF1AAAAAAACAY0AAAAAAAEBiQAAAAAAAgFtAAAAAAACAYkAAAAAAALByQAAAAAAAwHZAAAAAAAAgcUAAAAAAAMBsQAAAAAAAAGpAAAAAAABgZUAAAAAAAMBmQAAAAAAAQGNAAAAAAAAAaUAAAAAAACBkQAAAAAAAYGpAAAAAAADgZkAAAAAAAGBuQAAAAAAAAGlAAAAAAAAgaEAAAAAAAMBnQAAAAAAAgG9AAAAAAAAgZ0AAAAAAAIBrQAAAAAAAgGdAAAAAAADAakAAAAAAAKBtQAAAAAAAkHZAAAAAAADQdEAAAAAAAGBxQAAAAAAAoHNAAAAAAAAwcUAAAAAAAIBxQAAAAAAA4G5AAAAAAAAQcUAAAAAAADB2QAAAAAAAUHRAAAAAAAAAb0AAAAAAAABoQAAAAAAA4GtA\",\"dtype\":\"float64\",\"shape\":[132]}}},\"id\":\"c47e3267-6b74-4187-bded-8c065584356c\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"children\":[{\"id\":\"d6274d50-855b-45a1-8e52-40533a11f671\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"613e121a-2213-4688-b77e-7feb91135c18\",\"type\":\"Row\"},{\"attributes\":{\"overlay\":{\"id\":\"63e17c1b-cedc-4427-bc87-ff10cc2f06b3\",\"type\":\"BoxAnnotation\"}},\"id\":\"5048f2cb-9060-4c79-a45e-2bff7a44ab41\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"label\":{\"value\":\"Elvis\"},\"renderers\":[{\"id\":\"3b8f1241-1f5e-4678-8102-683cf1fbdea9\",\"type\":\"GlyphRenderer\"}]},\"id\":\"00ed8aaa-4873-458d-9c43-a8eb02b1ce7a\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"8f5bf34b-b828-4bb9-adc8-af9a885de897\",\"type\":\"SaveTool\"},{\"attributes\":{\"children\":[{\"id\":\"1d6b9143-f600-45d6-b4fd-8817979e9d2b\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"b2654c44-94a6-4182-94ea-e78bda505d01\",\"type\":\"Row\"},{\"attributes\":{},\"id\":\"0f4a6a1f-f987-450c-bc85-df66cee9d166\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"8445beba-06cc-4fd1-b647-4ddfece2571a\",\"type\":\"ResetTool\"},{\"attributes\":{\"callback\":null},\"id\":\"31f78c0d-5610-42ed-b305-f640f6a88b40\",\"type\":\"DataRange1d\"},{\"attributes\":{\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"5be17c9d-cdc2-49d0-805c-15209541fcf5\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"95c78650-54c6-485b-a67b-0dfbd79ea28b\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"0ab52112-dc05-40a5-8f01-4fc485711089\",\"type\":\"HelpTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"634dd819-5654-42c9-8ff4-8f7c50e9a3a4\",\"type\":\"PanTool\"},{\"id\":\"e001c5ec-f5d4-4fe7-82d2-8a7d8ed6fc83\",\"type\":\"WheelZoomTool\"},{\"id\":\"8de504ae-fe0e-4f3e-a93c-242c23933abb\",\"type\":\"BoxZoomTool\"},{\"id\":\"4e402708-1f02-49a4-963e-ba83daf9e8c1\",\"type\":\"SaveTool\"},{\"id\":\"91e6fff1-f0c3-461b-bc57-e64d4c7bf24f\",\"type\":\"ResetTool\"},{\"id\":\"352a30c9-3f9b-428d-9cc7-8fc0946cb403\",\"type\":\"HelpTool\"}]},\"id\":\"74377496-6433-4b57-a31c-e99f1a5296c0\",\"type\":\"Toolbar\"},{\"attributes\":{\"children\":[{\"id\":\"a9b68627-0b31-4c18-82de-a1ed928ce68c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"f83bb049-6491-4aa2-9075-412c8dfd53bb\",\"type\":\"Row\"},{\"attributes\":{},\"id\":\"8d0dd804-0347-47a6-9db6-5285d6fb39ad\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"a4f0ace5-4250-4482-a0ac-83f49093ce9d\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"children\":[{\"id\":\"4fb809e7-e85c-44ad-8377-f6d2202388dd\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"941902f2-94f3-45b3-91ae-691569dfb742\",\"type\":\"Row\"},{\"attributes\":{\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"d2e4d680-ad92-4502-b87e-9aff28819c76\",\"type\":\"Line\"},{\"attributes\":{\"source\":{\"id\":\"22a266c3-c342-445f-9aa9-7fe0e70ead9f\",\"type\":\"ColumnDataSource\"}},\"id\":\"738d1d5f-35c0-4dcf-bce2-c525603af9c4\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"117a43a8-0d7e-4210-bc42-164aad59017b\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"66cd2e9b-62d9-408d-8cf5-17d1963a82b3\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"children\":[{\"id\":\"c7fbca12-cc89-4512-9c64-5305c23a4de1\",\"type\":\"ToolbarBox\"},{\"id\":\"8e5d2bff-90f7-4d58-bf58-ed0c35519c6c\",\"type\":\"Column\"}]},\"id\":\"7726ccff-2e43-4004-a885-6a113f599b9d\",\"type\":\"Column\"},{\"attributes\":{\"formatter\":{\"id\":\"90db3e69-e284-4def-b3e1-3b16c879400d\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"d6274d50-855b-45a1-8e52-40533a11f671\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"ff64a8a6-5667-4474-b687-d32a275b8dab\",\"type\":\"BasicTicker\"}},\"id\":\"36b49aec-ec73-4dad-9b59-133a13614266\",\"type\":\"LinearAxis\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"0d5f13de-24ea-409d-86b5-4f1d035b3c71\",\"type\":\"PanTool\"},{\"id\":\"8eca0026-d74d-419c-8811-eb7018eb6a83\",\"type\":\"WheelZoomTool\"},{\"id\":\"438a5f1a-d467-4535-9709-764faa27ac46\",\"type\":\"BoxZoomTool\"},{\"id\":\"99093f1b-d2e5-4dcb-829e-416e9ed4e96e\",\"type\":\"SaveTool\"},{\"id\":\"7f6dd83a-c0fa-4d2f-800f-ac7c741fd929\",\"type\":\"ResetTool\"},{\"id\":\"64d226e4-b0af-4571-a7d5-977b756ae1c9\",\"type\":\"HelpTool\"}]},\"id\":\"367ce302-a104-40ad-b66c-c778c066cb9d\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"4e402708-1f02-49a4-963e-ba83daf9e8c1\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"938855e4-a561-4c06-b7b3-f5a32e8a788e\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"5e0c9959-5498-4604-8f4d-9f5c360f6f64\",\"type\":\"LinearScale\"},{\"attributes\":{\"plot\":{\"id\":\"a9b68627-0b31-4c18-82de-a1ed928ce68c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1d678dd0-63ee-4243-a34c-a003f286c374\",\"type\":\"BasicTicker\"}},\"id\":\"3a310fdf-db5c-4206-b4a8-b1de7eb17301\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"8beeba60-bce1-4628-81ee-23fd0e5a5301\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"d6274d50-855b-45a1-8e52-40533a11f671\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"34a45fdb-2e4e-41f0-b5f1-abeebcbf03be\",\"type\":\"BasicTicker\"}},\"id\":\"24ff075a-4b21-4db1-8ea7-d9d8c0da493d\",\"type\":\"LinearAxis\"},{\"attributes\":{\"items\":[{\"id\":\"12ace5cd-ceec-4036-9eb1-88d11da934f4\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"b5a41966-8acf-4e9d-9740-18b3e9fdec18\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"81703e83-84bb-466c-80fe-54c70d520392\",\"type\":\"Legend\"},{\"attributes\":{\"below\":[{\"id\":\"98ac091b-cb5b-4bdf-b3f0-3f10a4bd5e23\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"613ac4e7-74df-4ff6-9315-abf10c1d535b\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"plot_width\":700,\"renderers\":[{\"id\":\"98ac091b-cb5b-4bdf-b3f0-3f10a4bd5e23\",\"type\":\"LinearAxis\"},{\"id\":\"3a310fdf-db5c-4206-b4a8-b1de7eb17301\",\"type\":\"Grid\"},{\"id\":\"613ac4e7-74df-4ff6-9315-abf10c1d535b\",\"type\":\"LinearAxis\"},{\"id\":\"ce7e9ef8-2e15-4a0c-b7ae-61ea2c3bc2c6\",\"type\":\"Grid\"},{\"id\":\"51b63e0a-f90e-4d7e-a92d-9be77bfa4910\",\"type\":\"BoxAnnotation\"},{\"id\":\"a244cb9e-90f5-4655-b61a-28cd7bd13b0d\",\"type\":\"Legend\"},{\"id\":\"e26a3ef1-f85b-4143-9992-0e8951f60d85\",\"type\":\"GlyphRenderer\"}],\"title\":null,\"toolbar\":{\"id\":\"367ce302-a104-40ad-b66c-c778c066cb9d\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"e69e6333-8bdd-4b9e-ba2d-ffc49e12620e\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"14b21e44-c575-498a-ac5b-41053fdf70e1\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"7027f294-dfd1-4907-9711-6ccc8064ea87\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"938855e4-a561-4c06-b7b3-f5a32e8a788e\",\"type\":\"LinearScale\"}},\"id\":\"a9b68627-0b31-4c18-82de-a1ed928ce68c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"below\":[{\"id\":\"24ff075a-4b21-4db1-8ea7-d9d8c0da493d\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"36b49aec-ec73-4dad-9b59-133a13614266\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"plot_width\":700,\"renderers\":[{\"id\":\"24ff075a-4b21-4db1-8ea7-d9d8c0da493d\",\"type\":\"LinearAxis\"},{\"id\":\"8f6854d1-7fbf-4213-a376-a5407931106a\",\"type\":\"Grid\"},{\"id\":\"36b49aec-ec73-4dad-9b59-133a13614266\",\"type\":\"LinearAxis\"},{\"id\":\"eb8f8dea-ab65-4d6d-880e-b8cdf0e0cd80\",\"type\":\"Grid\"},{\"id\":\"ac8c2821-bad4-4b8f-8180-342b7ce8add9\",\"type\":\"BoxAnnotation\"},{\"id\":\"6e8f7d4c-e0e2-4478-8c78-325733b1040d\",\"type\":\"Legend\"},{\"id\":\"3b8f1241-1f5e-4678-8102-683cf1fbdea9\",\"type\":\"GlyphRenderer\"}],\"title\":null,\"toolbar\":{\"id\":\"7144d7a9-e625-48c9-9258-22519ff4c76d\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"39078493-c5f8-4a63-847d-19b92437dc9d\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"1098d9b8-2ab0-48c7-8a7c-a9b13eead76b\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"b959e299-d7d6-4614-ae6d-96ae9c386e49\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"5e0c9959-5498-4604-8f4d-9f5c360f6f64\",\"type\":\"LinearScale\"}},\"id\":\"d6274d50-855b-45a1-8e52-40533a11f671\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null},\"id\":\"e69e6333-8bdd-4b9e-ba2d-ffc49e12620e\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"ff64a8a6-5667-4474-b687-d32a275b8dab\",\"type\":\"BasicTicker\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4abd3503-3d51-487a-abeb-630da9a52fca\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"34a45fdb-2e4e-41f0-b5f1-abeebcbf03be\",\"type\":\"BasicTicker\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"d4eeffc0-686e-4782-a211-f4a0e84c3358\",\"type\":\"Line\"},{\"attributes\":{\"data_source\":{\"id\":\"2489db6e-0b76-405f-8210-7ba81715d3ff\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"a6bbbf58-dae5-4e3b-8e8d-8f5166dde96c\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"b34bdaba-b247-4224-a3e3-fef3aa5fe0a7\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"9ec74890-05ee-4de9-92de-b7f7e14743a3\",\"type\":\"CDSView\"}},\"id\":\"7a952bad-6602-48bc-b77a-3a01d0fe4086\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"label\":{\"value\":\"Marvin\"},\"renderers\":[{\"id\":\"e26a3ef1-f85b-4143-9992-0e8951f60d85\",\"type\":\"GlyphRenderer\"}]},\"id\":\"cf01ee92-956e-4349-9760-02f82affd688\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"29ce51b4-92fb-49c5-a05d-fc2bc39451f2\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"14b21e44-c575-498a-ac5b-41053fdf70e1\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null},\"id\":\"7027f294-dfd1-4907-9711-6ccc8064ea87\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"2669b31c-54dc-48b5-91ba-e08126766622\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"281b3c18-92c3-45be-b694-c3b6890f0d7f\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"89921bbc-98fa-4eaf-9a47-83661fe1eda1\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2669b31c-54dc-48b5-91ba-e08126766622\",\"type\":\"BasicTicker\"}},\"id\":\"91e13dad-6d7a-4d43-a2ac-cb4bb97a34ae\",\"type\":\"LinearAxis\"},{\"attributes\":{\"formatter\":{\"id\":\"c49d8fd0-4874-4af4-8f4b-f1ffa46cb3b7\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"a9b68627-0b31-4c18-82de-a1ed928ce68c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1d678dd0-63ee-4243-a34c-a003f286c374\",\"type\":\"BasicTicker\"}},\"id\":\"98ac091b-cb5b-4bdf-b3f0-3f10a4bd5e23\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"57db8f40-73c9-4e06-b8d7-e9603d2a8465\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1d678dd0-63ee-4243-a34c-a003f286c374\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"5c2d0777-047a-4c90-8ba9-2720b42faef9\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"a9b68627-0b31-4c18-82de-a1ed928ce68c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"52e1980a-ffda-4d87-95fc-f03e88ccca70\",\"type\":\"BasicTicker\"}},\"id\":\"613ac4e7-74df-4ff6-9315-abf10c1d535b\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"90db3e69-e284-4def-b3e1-3b16c879400d\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"52e1980a-ffda-4d87-95fc-f03e88ccca70\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"a9b68627-0b31-4c18-82de-a1ed928ce68c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"52e1980a-ffda-4d87-95fc-f03e88ccca70\",\"type\":\"BasicTicker\"}},\"id\":\"ce7e9ef8-2e15-4a0c-b7ae-61ea2c3bc2c6\",\"type\":\"Grid\"},{\"attributes\":{\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"5d1a8fdc-8b25-4e36-9817-aa06f6680a01\",\"type\":\"Line\"},{\"attributes\":{\"callback\":null},\"id\":\"b959e299-d7d6-4614-ae6d-96ae9c386e49\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":{\"__ndarray__\":\"AAAAAABAUUAAAAAAAIBMQAAAAAAAAFBAAAAAAADAUUAAAAAAAEBSQAAAAAAAQFBAAAAAAACAVkAAAAAAAIBRQAAAAAAAgFZAAAAAAABAU0AAAAAAAMBYQAAAAAAAQFdAAAAAAAAAVkAAAAAAAIBZQAAAAAAAAFdAAAAAAADAWkAAAAAAAEBXQAAAAAAAwGBAAAAAAADAX0AAAAAAAEBhQAAAAAAAAGZAAAAAAAAgYkAAAAAAAEBnQAAAAAAAIGdAAAAAAABgaUAAAAAAAOBqQAAAAAAAoG5AAAAAAAAAc0AAAAAAAHBzQAAAAAAAIHZAAAAAAADQeUAAAAAAAIB+QAAAAAAA8I1AAAAAAABQk0AAAAAAAGyZQAAAAAAAZqFAAAAAAADCo0AAAAAAAKqjQAAAAAAAGKZAAAAAAABsp0AAAAAAAFipQAAAAAAAQqtAAAAAAAD+q0AAAAAAAMytQAAAAAAAaK9AAAAAAAD4r0AAAAAAABWwQAAAAAAAJbFAAAAAAABlsUAAAAAAABmxQAAAAAAANLFAAAAAAAD9sEAAAAAAAFewQAAAAAAAILBAAAAAAAB+sEAAAAAAAKqwQAAAAAAAyK5AAAAAAACErkAAAAAAAHauQAAAAAAAWq1AAAAAAABeq0AAAAAAAEisQAAAAAAAoK1AAAAAAADCrkAAAAAAAOKrQAAAAAAArqlAAAAAAAAgrEAAAAAAAGitQAAAAAAARqxAAAAAAAAUrUAAAAAAAFirQAAAAAAArqtAAAAAAADyq0AAAAAAAMSrQAAAAAAAQqtAAAAAAACUrEAAAAAAADKrQAAAAAAAmKpAAAAAAACwqUAAAAAAAMyoQAAAAAAAmKlAAAAAAADWqEAAAAAAAH6oQAAAAAAAPKdAAAAAAAA2p0AAAAAAADanQAAAAAAAXKVAAAAAAAD8okAAAAAAAJ6hQAAAAAAANKFAAAAAAADIn0AAAAAAADCeQAAAAAAA/JhAAAAAAACEl0AAAAAAADCXQAAAAAAAgJRAAAAAAACYk0AAAAAAAFSSQAAAAAAAwJJAAAAAAABwk0AAAAAAABSTQAAAAAAARJJAAAAAAADAkUAAAAAAAFSSQAAAAAAANJFAAAAAAADYkUAAAAAAAMiRQAAAAAAA1JBAAAAAAAD4kUAAAAAAAJiSQAAAAAAA+JJAAAAAAACkkkAAAAAAAEySQAAAAAAA1JBAAAAAAABgjkAAAAAAABiKQAAAAAAACItAAAAAAAC4ikAAAAAAACCKQAAAAAAAuIdAAAAAAAA4iUAAAAAAANiIQAAAAAAA0IhAAAAAAADwikAAAAAAANCIQAAAAAAAKIlAAAAAAADIi0AAAAAAAHCLQAAAAAAAwIlAAAAAAADohUAAAAAAAMCDQAAAAAAA0IFA\",\"dtype\":\"float64\",\"shape\":[132]}}},\"id\":\"ca61898f-7817-4a06-a7ab-deb12c19da36\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"plot\":{\"id\":\"89921bbc-98fa-4eaf-9a47-83661fe1eda1\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"2669b31c-54dc-48b5-91ba-e08126766622\",\"type\":\"BasicTicker\"}},\"id\":\"640b8dd2-9edc-4c42-9e40-dc3b624d2eeb\",\"type\":\"Grid\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"8d0dd804-0347-47a6-9db6-5285d6fb39ad\",\"type\":\"PanTool\"},{\"id\":\"15fe67b2-36c4-48ff-a128-64798243aaf8\",\"type\":\"WheelZoomTool\"},{\"id\":\"a61f06eb-bbc2-4362-b77d-cecc627c57a8\",\"type\":\"BoxZoomTool\"},{\"id\":\"60b88684-9c2a-466b-ad59-89c188a43823\",\"type\":\"SaveTool\"},{\"id\":\"0ffb9c5c-6232-4fde-bfff-83a3e155889b\",\"type\":\"ResetTool\"},{\"id\":\"4c78a652-988c-4d2e-82f0-47452691a3c5\",\"type\":\"HelpTool\"}]},\"id\":\"f4e085f7-164b-4b30-81a2-0f0e82907571\",\"type\":\"Toolbar\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"51b63e0a-f90e-4d7e-a92d-9be77bfa4910\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"source\":{\"id\":\"2bc40f88-f258-4ac3-8459-c8db26f87be6\",\"type\":\"ColumnDataSource\"}},\"id\":\"827c2ea2-1e5c-44e6-a253-af5f5156bece\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"0d5f13de-24ea-409d-86b5-4f1d035b3c71\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"1098d9b8-2ab0-48c7-8a7c-a9b13eead76b\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"7c2aef2b-2a56-4a11-8b1d-84a572a0e8de\",\"type\":\"BasicTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"ca61898f-7817-4a06-a7ab-deb12c19da36\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"5d1a8fdc-8b25-4e36-9817-aa06f6680a01\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"d4eeffc0-686e-4782-a211-f4a0e84c3358\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"69583945-8742-4d03-8227-5a18e53b72e0\",\"type\":\"CDSView\"}},\"id\":\"e26a3ef1-f85b-4143-9992-0e8951f60d85\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"463cda52-9ed1-4f20-8275-0b34d03e0866\",\"type\":\"Line\"},{\"attributes\":{\"children\":[{\"id\":\"75e904ff-6b23-4568-aa5d-521ece598627\",\"type\":\"Row\"},{\"id\":\"613e121a-2213-4688-b77e-7feb91135c18\",\"type\":\"Row\"},{\"id\":\"b2654c44-94a6-4182-94ea-e78bda505d01\",\"type\":\"Row\"},{\"id\":\"bfe5c944-a609-49ba-b95a-59e282e16a02\",\"type\":\"Row\"},{\"id\":\"f83bb049-6491-4aa2-9075-412c8dfd53bb\",\"type\":\"Row\"},{\"id\":\"941902f2-94f3-45b3-91ae-691569dfb742\",\"type\":\"Row\"}]},\"id\":\"8e5d2bff-90f7-4d58-bf58-ed0c35519c6c\",\"type\":\"Column\"},{\"attributes\":{},\"id\":\"8eca0026-d74d-419c-8811-eb7018eb6a83\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"d6274d50-855b-45a1-8e52-40533a11f671\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"ff64a8a6-5667-4474-b687-d32a275b8dab\",\"type\":\"BasicTicker\"}},\"id\":\"eb8f8dea-ab65-4d6d-880e-b8cdf0e0cd80\",\"type\":\"Grid\"},{\"attributes\":{\"overlay\":{\"id\":\"51b63e0a-f90e-4d7e-a92d-9be77bfa4910\",\"type\":\"BoxAnnotation\"}},\"id\":\"438a5f1a-d467-4535-9709-764faa27ac46\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"source\":{\"id\":\"c47e3267-6b74-4187-bded-8c065584356c\",\"type\":\"ColumnDataSource\"}},\"id\":\"85006748-2c63-4edc-b8fd-0452f2b13e1f\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"99093f1b-d2e5-4dcb-829e-416e9ed4e96e\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"9dfb5cd8-3bdd-4641-be9a-bcf707e15cc2\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"7f6dd83a-c0fa-4d2f-800f-ac7c741fd929\",\"type\":\"ResetTool\"},{\"attributes\":{\"callback\":null},\"id\":\"bbebd694-b026-4809-94ad-b0d54dd54811\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":{\"id\":\"1d6b9143-f600-45d6-b4fd-8817979e9d2b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"17a8d788-9c5b-4b05-a6e6-a6ddf3ad982d\",\"type\":\"BasicTicker\"}},\"id\":\"dedfa696-7789-4635-9b03-5e4e473ba053\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"64d226e4-b0af-4571-a7d5-977b756ae1c9\",\"type\":\"HelpTool\"},{\"attributes\":{\"below\":[{\"id\":\"91e13dad-6d7a-4d43-a2ac-cb4bb97a34ae\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"0a0b3163-b9d5-4e6c-a0e2-dd1fb5e14c85\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"plot_width\":700,\"renderers\":[{\"id\":\"91e13dad-6d7a-4d43-a2ac-cb4bb97a34ae\",\"type\":\"LinearAxis\"},{\"id\":\"640b8dd2-9edc-4c42-9e40-dc3b624d2eeb\",\"type\":\"Grid\"},{\"id\":\"0a0b3163-b9d5-4e6c-a0e2-dd1fb5e14c85\",\"type\":\"LinearAxis\"},{\"id\":\"7d6e6de9-60d3-435b-b05b-512dc652e5ad\",\"type\":\"Grid\"},{\"id\":\"66463383-4687-4a77-81c4-9c888247fc69\",\"type\":\"BoxAnnotation\"},{\"id\":\"9e786ec5-3df6-4980-8a3d-2c2bc2687f79\",\"type\":\"Legend\"},{\"id\":\"8c345eb4-75a1-4743-9e40-86ce644c87d5\",\"type\":\"GlyphRenderer\"}],\"title\":null,\"toolbar\":{\"id\":\"74377496-6433-4b57-a31c-e99f1a5296c0\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"875d1a97-1f7f-4661-b5d7-08154c689f39\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"e97122f8-41d9-455b-9711-09bb1ee21672\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"31f78c0d-5610-42ed-b305-f640f6a88b40\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"47f61ad4-652e-4662-bd56-94a51ddae90f\",\"type\":\"LinearScale\"}},\"id\":\"89921bbc-98fa-4eaf-9a47-83661fe1eda1\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"items\":[{\"id\":\"00ed8aaa-4873-458d-9c43-a8eb02b1ce7a\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"d6274d50-855b-45a1-8e52-40533a11f671\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"6e8f7d4c-e0e2-4478-8c78-325733b1040d\",\"type\":\"Legend\"},{\"attributes\":{\"callback\":null},\"id\":\"39078493-c5f8-4a63-847d-19b92437dc9d\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"c49d8fd0-4874-4af4-8f4b-f1ffa46cb3b7\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"b34bdaba-b247-4224-a3e3-fef3aa5fe0a7\",\"type\":\"Line\"},{\"attributes\":{\"source\":{\"id\":\"ca61898f-7817-4a06-a7ab-deb12c19da36\",\"type\":\"ColumnDataSource\"}},\"id\":\"69583945-8742-4d03-8227-5a18e53b72e0\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"f7ee5da9-e9bd-4549-bec2-c215aeab39ca\",\"type\":\"BasicTicker\"},{\"attributes\":{\"below\":[{\"id\":\"053d7b36-1069-4e64-9fe4-f467b5e91f22\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"ff997085-9c0f-461d-841e-d54c7635d0ef\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"plot_width\":700,\"renderers\":[{\"id\":\"053d7b36-1069-4e64-9fe4-f467b5e91f22\",\"type\":\"LinearAxis\"},{\"id\":\"dedfa696-7789-4635-9b03-5e4e473ba053\",\"type\":\"Grid\"},{\"id\":\"ff997085-9c0f-461d-841e-d54c7635d0ef\",\"type\":\"LinearAxis\"},{\"id\":\"9cdee14a-e717-45e6-8291-8df9686bfa72\",\"type\":\"Grid\"},{\"id\":\"6e0ecfcd-8a20-4eac-896b-fd5ae0fbe391\",\"type\":\"BoxAnnotation\"},{\"id\":\"1f5ea08b-a4f7-4424-83b4-ae154a1607de\",\"type\":\"Legend\"},{\"id\":\"7a952bad-6602-48bc-b77a-3a01d0fe4086\",\"type\":\"GlyphRenderer\"}],\"title\":null,\"toolbar\":{\"id\":\"f4e085f7-164b-4b30-81a2-0f0e82907571\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"daf26933-453e-4bbb-85fe-59a71068e5c1\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"7863a767-4cbc-4ebc-81eb-078143a3356c\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"bbebd694-b026-4809-94ad-b0d54dd54811\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"9dfb5cd8-3bdd-4641-be9a-bcf707e15cc2\",\"type\":\"LinearScale\"}},\"id\":\"1d6b9143-f600-45d6-b4fd-8817979e9d2b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"5c2d0777-047a-4c90-8ba9-2720b42faef9\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":null},\"id\":\"daf26933-453e-4bbb-85fe-59a71068e5c1\",\"type\":\"DataRange1d\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"2cda92ea-3cc7-430d-8632-30be536b3d7d\",\"type\":\"PanTool\"},{\"id\":\"ff4de11a-e3a3-4cea-8a11-f20609b33479\",\"type\":\"WheelZoomTool\"},{\"id\":\"96104903-69e1-4a63-9be3-26fecb0eb35f\",\"type\":\"BoxZoomTool\"},{\"id\":\"95bfe4b9-2791-4ed2-b843-516c3df28dd6\",\"type\":\"SaveTool\"},{\"id\":\"b9f39a6b-e5db-4c46-ac88-254b58e1ba8b\",\"type\":\"ResetTool\"},{\"id\":\"2d3fbe6c-390c-426c-9d8c-d32087d6acb6\",\"type\":\"HelpTool\"}]},\"id\":\"d76476bd-2c80-411d-8684-51d364fe1aee\",\"type\":\"Toolbar\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"89921bbc-98fa-4eaf-9a47-83661fe1eda1\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"7c2aef2b-2a56-4a11-8b1d-84a572a0e8de\",\"type\":\"BasicTicker\"}},\"id\":\"7d6e6de9-60d3-435b-b05b-512dc652e5ad\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"f61f6707-8dc0-4a7a-9c2a-2485ae0e4255\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1d6b9143-f600-45d6-b4fd-8817979e9d2b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"17a8d788-9c5b-4b05-a6e6-a6ddf3ad982d\",\"type\":\"BasicTicker\"}},\"id\":\"053d7b36-1069-4e64-9fe4-f467b5e91f22\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"781f9c00-bf31-4254-b7f5-46a43feca829\",\"type\":\"LinearScale\"},{\"attributes\":{\"plot\":{\"id\":\"4fb809e7-e85c-44ad-8377-f6d2202388dd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"f7ee5da9-e9bd-4549-bec2-c215aeab39ca\",\"type\":\"BasicTicker\"}},\"id\":\"67d578dc-247c-486e-80af-395af689dd82\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"f61f6707-8dc0-4a7a-9c2a-2485ae0e4255\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"formatter\":{\"id\":\"57db8f40-73c9-4e06-b8d7-e9603d2a8465\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"89921bbc-98fa-4eaf-9a47-83661fe1eda1\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"7c2aef2b-2a56-4a11-8b1d-84a572a0e8de\",\"type\":\"BasicTicker\"}},\"id\":\"0a0b3163-b9d5-4e6c-a0e2-dd1fb5e14c85\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"7863a767-4cbc-4ebc-81eb-078143a3356c\",\"type\":\"LinearScale\"},{\"attributes\":{\"items\":[{\"id\":\"cf01ee92-956e-4349-9760-02f82affd688\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"a9b68627-0b31-4c18-82de-a1ed928ce68c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"a244cb9e-90f5-4655-b61a-28cd7bd13b0d\",\"type\":\"Legend\"},{\"attributes\":{\"below\":[{\"id\":\"04a8b8ac-4644-4867-9879-7f93ecaf75d3\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"c2ced20e-2fa6-4e35-bd3c-a5c414599a4c\",\"type\":\"LinearAxis\"}],\"plot_height\":200,\"plot_width\":700,\"renderers\":[{\"id\":\"04a8b8ac-4644-4867-9879-7f93ecaf75d3\",\"type\":\"LinearAxis\"},{\"id\":\"67d578dc-247c-486e-80af-395af689dd82\",\"type\":\"Grid\"},{\"id\":\"c2ced20e-2fa6-4e35-bd3c-a5c414599a4c\",\"type\":\"LinearAxis\"},{\"id\":\"6259ae44-4bd7-41c6-b6f1-2d737a59c0ca\",\"type\":\"Grid\"},{\"id\":\"0eec9790-d453-4234-b54a-b955b07fd96d\",\"type\":\"BoxAnnotation\"},{\"id\":\"86a07eeb-79fe-4195-a7c5-746949084fb6\",\"type\":\"Legend\"},{\"id\":\"d2dc96c5-37bd-4eaf-9990-bcfb8cfef5fd\",\"type\":\"GlyphRenderer\"}],\"title\":null,\"toolbar\":{\"id\":\"d76476bd-2c80-411d-8684-51d364fe1aee\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"53dee981-efe3-4dbc-9c4a-8f1e174dba89\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"953502ab-7445-42cb-9242-0eb493e14d1e\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"71f9f581-35c4-4526-a4ac-f1c19eefcdb4\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"781f9c00-bf31-4254-b7f5-46a43feca829\",\"type\":\"LinearScale\"}},\"id\":\"4fb809e7-e85c-44ad-8377-f6d2202388dd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"17a8d788-9c5b-4b05-a6e6-a6ddf3ad982d\",\"type\":\"BasicTicker\"},{\"attributes\":{\"items\":[{\"id\":\"c1d87268-e475-48d6-83d5-821d0edaae27\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"89921bbc-98fa-4eaf-9a47-83661fe1eda1\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"9e786ec5-3df6-4980-8a3d-2c2bc2687f79\",\"type\":\"Legend\"},{\"attributes\":{\"callback\":null},\"id\":\"53dee981-efe3-4dbc-9c4a-8f1e174dba89\",\"type\":\"DataRange1d\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"1d6b9143-f600-45d6-b4fd-8817979e9d2b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"3cd54447-fd3b-43f7-961a-54340e6d32d3\",\"type\":\"BasicTicker\"}},\"id\":\"9cdee14a-e717-45e6-8291-8df9686bfa72\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"f80471cb-1daf-4d56-a348-b3f5b7824011\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"1d6b9143-f600-45d6-b4fd-8817979e9d2b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"3cd54447-fd3b-43f7-961a-54340e6d32d3\",\"type\":\"BasicTicker\"}},\"id\":\"ff997085-9c0f-461d-841e-d54c7635d0ef\",\"type\":\"LinearAxis\"},{\"attributes\":{\"formatter\":{\"id\":\"111efeda-f619-4c81-a95e-6cfef28cf2c2\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4fb809e7-e85c-44ad-8377-f6d2202388dd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"ee2e69ce-ca7a-4715-934d-bf5a1be636e0\",\"type\":\"BasicTicker\"}},\"id\":\"c2ced20e-2fa6-4e35-bd3c-a5c414599a4c\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"953502ab-7445-42cb-9242-0eb493e14d1e\",\"type\":\"LinearScale\"},{\"attributes\":{\"label\":{\"value\":\"Ray\"},\"renderers\":[{\"id\":\"8c345eb4-75a1-4743-9e40-86ce644c87d5\",\"type\":\"GlyphRenderer\"}]},\"id\":\"c1d87268-e475-48d6-83d5-821d0edaae27\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"3cd54447-fd3b-43f7-961a-54340e6d32d3\",\"type\":\"BasicTicker\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"6e0ecfcd-8a20-4eac-896b-fd5ae0fbe391\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"b39d5651-de00-490c-a10e-0b7dda6cfdd6\",\"type\":\"PanTool\"},{\"id\":\"29ce51b4-92fb-49c5-a05d-fc2bc39451f2\",\"type\":\"WheelZoomTool\"},{\"id\":\"3565a083-99df-4e3a-8061-0010d771b691\",\"type\":\"BoxZoomTool\"},{\"id\":\"8f5bf34b-b828-4bb9-adc8-af9a885de897\",\"type\":\"SaveTool\"},{\"id\":\"95c78650-54c6-485b-a67b-0dfbd79ea28b\",\"type\":\"ResetTool\"},{\"id\":\"117a43a8-0d7e-4210-bc42-164aad59017b\",\"type\":\"HelpTool\"}]},\"id\":\"7144d7a9-e625-48c9-9258-22519ff4c76d\",\"type\":\"Toolbar\"},{\"attributes\":{\"callback\":null},\"id\":\"71f9f581-35c4-4526-a4ac-f1c19eefcdb4\",\"type\":\"DataRange1d\"},{\"attributes\":{\"formatter\":{\"id\":\"6c9e4767-8202-497a-a379-c4169e8d0fb0\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"4fb809e7-e85c-44ad-8377-f6d2202388dd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"f7ee5da9-e9bd-4549-bec2-c215aeab39ca\",\"type\":\"BasicTicker\"}},\"id\":\"04a8b8ac-4644-4867-9879-7f93ecaf75d3\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":{\"__ndarray__\":\"AAAAAADAYUAAAAAAAIBiQAAAAAAAYGhAAAAAAABAaUAAAAAAAABtQAAAAAAAoG1AAAAAAADwcEAAAAAAACBwQAAAAAAAsHRAAAAAAAAwdkAAAAAAANB1QAAAAAAAgHZAAAAAAAAQeEAAAAAAAKB3QAAAAAAAsHdAAAAAAADAd0AAAAAAAKB6QAAAAAAAwHhAAAAAAACgeEAAAAAAALBzQAAAAAAAkHxAAAAAAAAgdUAAAAAAAHB4QAAAAAAA0HhAAAAAAAAAe0AAAAAAAIB6QAAAAAAAUHpAAAAAAACwfUAAAAAAAPB7QAAAAAAAsH1AAAAAAAAIgUAAAAAAANCCQAAAAAAAZJBAAAAAAADAlEAAAAAAAOSZQAAAAAAAeqJAAAAAAAA8okAAAAAAAPiiQAAAAAAAlKVAAAAAAABGpUAAAAAAAByoQAAAAAAABKhAAAAAAADap0AAAAAAALaoQAAAAAAATKpAAAAAAAAkqUAAAAAAAKKqQAAAAAAAYKlAAAAAAABkqUAAAAAAAMqoQAAAAAAAZKlAAAAAAACwqEAAAAAAAHKpQAAAAAAArKdAAAAAAADGqEAAAAAAAPanQAAAAAAA9KZAAAAAAABMpUAAAAAAAHqmQAAAAAAAKqVAAAAAAADapUAAAAAAAAalQAAAAAAA7KdAAAAAAADup0AAAAAAAK6mQAAAAAAAaKVAAAAAAADGqEAAAAAAAF6qQAAAAAAAfKhAAAAAAAAgpUAAAAAAAJKkQAAAAAAA2qRAAAAAAAAMpUAAAAAAAOSlQAAAAAAARKdAAAAAAADkp0AAAAAAADqpQAAAAAAAqqpAAAAAAADkqEAAAAAAACCpQAAAAAAADqhAAAAAAADSpkAAAAAAAOikQAAAAAAALKRAAAAAAADEoUAAAAAAAE6gQAAAAAAAhJxAAAAAAABMmUAAAAAAAOSYQAAAAAAA2JdAAAAAAADglkAAAAAAALyTQAAAAAAAcJJAAAAAAABYkEAAAAAAAOiNQAAAAAAA8ItAAAAAAACIikAAAAAAADiJQAAAAAAAwIhAAAAAAAC4iUAAAAAAAEiKQAAAAAAAuIpAAAAAAAAQi0AAAAAAAOCHQAAAAAAA6IdAAAAAAAAAiEAAAAAAACCHQAAAAAAAAIhAAAAAAAA4h0AAAAAAAIiGQAAAAAAAmIdAAAAAAACohUAAAAAAADCCQAAAAAAAkIFAAAAAAACggUAAAAAAAPB+QAAAAAAAwHtAAAAAAACwe0AAAAAAANB7QAAAAAAA4HlAAAAAAAAwe0AAAAAAAGB2QAAAAAAAgHdAAAAAAAAAdUAAAAAAAGB4QAAAAAAAMHpAAAAAAAAQfEAAAAAAANB3QAAAAAAAAHdAAAAAAADAdkAAAAAAALB2QAAAAAAAYHVA\",\"dtype\":\"float64\",\"shape\":[132]}}},\"id\":\"2bc40f88-f258-4ac3-8459-c8db26f87be6\",\"type\":\"ColumnDataSource\"}],\"root_ids\":[\"7726ccff-2e43-4004-a885-6a113f599b9d\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.13\"}};\n",
" var render_items = [{\"docid\":\"d64242e8-c5e8-47b6-9a17-2cd2f6fd3c08\",\"elementid\":\"508355e4-e4df-48ca-9946-115d07d3d5e8\",\"modelid\":\"7726ccff-2e43-4004-a885-6a113f599b9d\"}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" clearInterval(timer);\n",
" }\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\")\n",
" clearInterval(timer);\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "7726ccff-2e43-4004-a885-6a113f599b9d"
}
},
"output_type": "display_data"
}
],
"source": [
"bBirths = boys.pivot_table('births', index='year', columns='name',\n",
" aggfunc=sum, margins=False)\n",
"subset = bBirths[['Ray', 'Elvis', 'Sam', 'John', 'Marvin', 'Bob']]\n",
"\n",
"plots = []\n",
"for name in subset.columns:\n",
" fig = bk.figure(plot_height=200, plot_width=700, title=None)\n",
" fig.line(x=np.asarray(subset.index), y=np.asarray(subset[name]),\n",
" line_color='black', legend=name)\n",
" plots.append([fig])\n",
"bk.show(bk.gridplot(plots))\n",
"\n",
"# Or directly using Pandas (which uses Matplotlib, not Bokeh): \n",
"#subset.plot(subplots=True, figsize=(12, 10), grid=False,\n",
"# title=\"Number of births per year\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4 Using 'groupby'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we are going to add a `column` named 'prop` that shows the ratio: $\\frac{\\text{children with a specific name}}{\\text{total children}}$"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def add_prop(group):\n",
" births = group['births']\n",
" group['prop'] = births/float(births.sum())\n",
" return group"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" name | \n",
" sex | \n",
" births | \n",
" year | \n",
" prop | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" Mary | \n",
" F | \n",
" 7065 | \n",
" 1880 | \n",
" 0.077642 | \n",
"
\n",
" \n",
" | 1 | \n",
" Anna | \n",
" F | \n",
" 2604 | \n",
" 1880 | \n",
" 0.028617 | \n",
"
\n",
" \n",
" | 2 | \n",
" Emma | \n",
" F | \n",
" 2003 | \n",
" 1880 | \n",
" 0.022012 | \n",
"
\n",
" \n",
" | 3 | \n",
" Elizabeth | \n",
" F | \n",
" 1939 | \n",
" 1880 | \n",
" 0.021309 | \n",
"
\n",
" \n",
" | 4 | \n",
" Minnie | \n",
" F | \n",
" 1746 | \n",
" 1880 | \n",
" 0.019188 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" name sex births year prop\n",
"0 Mary F 7065 1880 0.077642\n",
"1 Anna F 2604 1880 0.028617\n",
"2 Emma F 2003 1880 0.022012\n",
"3 Elizabeth F 1939 1880 0.021309\n",
"4 Minnie F 1746 1880 0.019188"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"names = names.groupby(['year', 'sex']).apply(add_prop)\n",
"display(names.head())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's check our calculations by verifying that the sum of all porportions by sex must be equal (or at least close) to 1."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.allclose(names.groupby(['year', 'sex'])['prop'].sum(), 1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we want to extract the top names for each sex/year combination."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" | \n",
" | \n",
" name | \n",
" sex | \n",
" births | \n",
" year | \n",
" prop | \n",
"
\n",
" \n",
" | year_ | \n",
" sex_ | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 1880 | \n",
" F | \n",
" 0 | \n",
" Mary | \n",
" F | \n",
" 7065 | \n",
" 1880 | \n",
" 0.077642 | \n",
"
\n",
" \n",
" | 1 | \n",
" Anna | \n",
" F | \n",
" 2604 | \n",
" 1880 | \n",
" 0.028617 | \n",
"
\n",
" \n",
" | 2 | \n",
" Emma | \n",
" F | \n",
" 2003 | \n",
" 1880 | \n",
" 0.022012 | \n",
"
\n",
" \n",
" | 3 | \n",
" Elizabeth | \n",
" F | \n",
" 1939 | \n",
" 1880 | \n",
" 0.021309 | \n",
"
\n",
" \n",
" | 4 | \n",
" Minnie | \n",
" F | \n",
" 1746 | \n",
" 1880 | \n",
" 0.019188 | \n",
"
\n",
" \n",
" | 5 | \n",
" Margaret | \n",
" F | \n",
" 1578 | \n",
" 1880 | \n",
" 0.017342 | \n",
"
\n",
" \n",
" | 6 | \n",
" Ida | \n",
" F | \n",
" 1472 | \n",
" 1880 | \n",
" 0.016177 | \n",
"
\n",
" \n",
" | 7 | \n",
" Alice | \n",
" F | \n",
" 1414 | \n",
" 1880 | \n",
" 0.015539 | \n",
"
\n",
" \n",
" | 8 | \n",
" Bertha | \n",
" F | \n",
" 1320 | \n",
" 1880 | \n",
" 0.014506 | \n",
"
\n",
" \n",
" | 9 | \n",
" Sarah | \n",
" F | \n",
" 1288 | \n",
" 1880 | \n",
" 0.014155 | \n",
"
\n",
" \n",
" | M | \n",
" 942 | \n",
" John | \n",
" M | \n",
" 9655 | \n",
" 1880 | \n",
" 0.087382 | \n",
"
\n",
" \n",
" | 943 | \n",
" William | \n",
" M | \n",
" 9533 | \n",
" 1880 | \n",
" 0.086278 | \n",
"
\n",
" \n",
" | 944 | \n",
" James | \n",
" M | \n",
" 5927 | \n",
" 1880 | \n",
" 0.053642 | \n",
"
\n",
" \n",
" | 945 | \n",
" Charles | \n",
" M | \n",
" 5348 | \n",
" 1880 | \n",
" 0.048402 | \n",
"
\n",
" \n",
" | 946 | \n",
" George | \n",
" M | \n",
" 5126 | \n",
" 1880 | \n",
" 0.046392 | \n",
"
\n",
" \n",
" | 947 | \n",
" Frank | \n",
" M | \n",
" 3242 | \n",
" 1880 | \n",
" 0.029341 | \n",
"
\n",
" \n",
" | 948 | \n",
" Joseph | \n",
" M | \n",
" 2632 | \n",
" 1880 | \n",
" 0.023821 | \n",
"
\n",
" \n",
" | 949 | \n",
" Thomas | \n",
" M | \n",
" 2534 | \n",
" 1880 | \n",
" 0.022934 | \n",
"
\n",
" \n",
" | 950 | \n",
" Henry | \n",
" M | \n",
" 2444 | \n",
" 1880 | \n",
" 0.022119 | \n",
"
\n",
" \n",
" | 951 | \n",
" Robert | \n",
" M | \n",
" 2415 | \n",
" 1880 | \n",
" 0.021857 | \n",
"
\n",
" \n",
" | 1881 | \n",
" F | \n",
" 2000 | \n",
" Mary | \n",
" F | \n",
" 6919 | \n",
" 1881 | \n",
" 0.075243 | \n",
"
\n",
" \n",
" | 2001 | \n",
" Anna | \n",
" F | \n",
" 2698 | \n",
" 1881 | \n",
" 0.029340 | \n",
"
\n",
" \n",
" | 2002 | \n",
" Emma | \n",
" F | \n",
" 2034 | \n",
" 1881 | \n",
" 0.022120 | \n",
"
\n",
" \n",
" | 2003 | \n",
" Elizabeth | \n",
" F | \n",
" 1852 | \n",
" 1881 | \n",
" 0.020140 | \n",
"
\n",
" \n",
" | 2004 | \n",
" Margaret | \n",
" F | \n",
" 1658 | \n",
" 1881 | \n",
" 0.018031 | \n",
"
\n",
" \n",
" | 2005 | \n",
" Minnie | \n",
" F | \n",
" 1653 | \n",
" 1881 | \n",
" 0.017976 | \n",
"
\n",
" \n",
" | 2006 | \n",
" Ida | \n",
" F | \n",
" 1439 | \n",
" 1881 | \n",
" 0.015649 | \n",
"
\n",
" \n",
" | 2007 | \n",
" Annie | \n",
" F | \n",
" 1326 | \n",
" 1881 | \n",
" 0.014420 | \n",
"
\n",
" \n",
" | 2008 | \n",
" Bertha | \n",
" F | \n",
" 1324 | \n",
" 1881 | \n",
" 0.014398 | \n",
"
\n",
" \n",
" | 2009 | \n",
" Alice | \n",
" F | \n",
" 1308 | \n",
" 1881 | \n",
" 0.014224 | \n",
"
\n",
" \n",
" | M | \n",
" 2938 | \n",
" John | \n",
" M | \n",
" 8769 | \n",
" 1881 | \n",
" 0.087040 | \n",
"
\n",
" \n",
" | 2939 | \n",
" William | \n",
" M | \n",
" 8524 | \n",
" 1881 | \n",
" 0.084608 | \n",
"
\n",
" \n",
" | 2940 | \n",
" James | \n",
" M | \n",
" 5442 | \n",
" 1881 | \n",
" 0.054016 | \n",
"
\n",
" \n",
" | 2941 | \n",
" George | \n",
" M | \n",
" 4664 | \n",
" 1881 | \n",
" 0.046294 | \n",
"
\n",
" \n",
" | 2942 | \n",
" Charles | \n",
" M | \n",
" 4636 | \n",
" 1881 | \n",
" 0.046016 | \n",
"
\n",
" \n",
" | 2943 | \n",
" Frank | \n",
" M | \n",
" 2834 | \n",
" 1881 | \n",
" 0.028130 | \n",
"
\n",
" \n",
" | 2944 | \n",
" Joseph | \n",
" M | \n",
" 2456 | \n",
" 1881 | \n",
" 0.024378 | \n",
"
\n",
" \n",
" | 2945 | \n",
" Henry | \n",
" M | \n",
" 2339 | \n",
" 1881 | \n",
" 0.023217 | \n",
"
\n",
" \n",
" | 2946 | \n",
" Thomas | \n",
" M | \n",
" 2282 | \n",
" 1881 | \n",
" 0.022651 | \n",
"
\n",
" \n",
" | 2947 | \n",
" Edward | \n",
" M | \n",
" 2177 | \n",
" 1881 | \n",
" 0.021609 | \n",
"
\n",
" \n",
" | 1882 | \n",
" F | \n",
" 3935 | \n",
" Mary | \n",
" F | \n",
" 8149 | \n",
" 1882 | \n",
" 0.075558 | \n",
"
\n",
" \n",
" | 3936 | \n",
" Anna | \n",
" F | \n",
" 3143 | \n",
" 1882 | \n",
" 0.029142 | \n",
"
\n",
" \n",
" | 3937 | \n",
" Emma | \n",
" F | \n",
" 2303 | \n",
" 1882 | \n",
" 0.021354 | \n",
"
\n",
" \n",
" | 3938 | \n",
" Elizabeth | \n",
" F | \n",
" 2187 | \n",
" 1882 | \n",
" 0.020278 | \n",
"
\n",
" \n",
" | 3939 | \n",
" Minnie | \n",
" F | \n",
" 2004 | \n",
" 1882 | \n",
" 0.018581 | \n",
"
\n",
" \n",
" | 3940 | \n",
" Margaret | \n",
" F | \n",
" 1821 | \n",
" 1882 | \n",
" 0.016884 | \n",
"
\n",
" \n",
" | 3941 | \n",
" Ida | \n",
" F | \n",
" 1673 | \n",
" 1882 | \n",
" 0.015512 | \n",
"
\n",
" \n",
" | 3942 | \n",
" Alice | \n",
" F | \n",
" 1542 | \n",
" 1882 | \n",
" 0.014298 | \n",
"
\n",
" \n",
" | 3943 | \n",
" Bertha | \n",
" F | \n",
" 1508 | \n",
" 1882 | \n",
" 0.013982 | \n",
"
\n",
" \n",
" | 3944 | \n",
" Annie | \n",
" F | \n",
" 1492 | \n",
" 1882 | \n",
" 0.013834 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" name sex births year prop\n",
"year_ sex_ \n",
"1880 F 0 Mary F 7065 1880 0.077642\n",
" 1 Anna F 2604 1880 0.028617\n",
" 2 Emma F 2003 1880 0.022012\n",
" 3 Elizabeth F 1939 1880 0.021309\n",
" 4 Minnie F 1746 1880 0.019188\n",
" 5 Margaret F 1578 1880 0.017342\n",
" 6 Ida F 1472 1880 0.016177\n",
" 7 Alice F 1414 1880 0.015539\n",
" 8 Bertha F 1320 1880 0.014506\n",
" 9 Sarah F 1288 1880 0.014155\n",
" M 942 John M 9655 1880 0.087382\n",
" 943 William M 9533 1880 0.086278\n",
" 944 James M 5927 1880 0.053642\n",
" 945 Charles M 5348 1880 0.048402\n",
" 946 George M 5126 1880 0.046392\n",
" 947 Frank M 3242 1880 0.029341\n",
" 948 Joseph M 2632 1880 0.023821\n",
" 949 Thomas M 2534 1880 0.022934\n",
" 950 Henry M 2444 1880 0.022119\n",
" 951 Robert M 2415 1880 0.021857\n",
"1881 F 2000 Mary F 6919 1881 0.075243\n",
" 2001 Anna F 2698 1881 0.029340\n",
" 2002 Emma F 2034 1881 0.022120\n",
" 2003 Elizabeth F 1852 1881 0.020140\n",
" 2004 Margaret F 1658 1881 0.018031\n",
" 2005 Minnie F 1653 1881 0.017976\n",
" 2006 Ida F 1439 1881 0.015649\n",
" 2007 Annie F 1326 1881 0.014420\n",
" 2008 Bertha F 1324 1881 0.014398\n",
" 2009 Alice F 1308 1881 0.014224\n",
" M 2938 John M 8769 1881 0.087040\n",
" 2939 William M 8524 1881 0.084608\n",
" 2940 James M 5442 1881 0.054016\n",
" 2941 George M 4664 1881 0.046294\n",
" 2942 Charles M 4636 1881 0.046016\n",
" 2943 Frank M 2834 1881 0.028130\n",
" 2944 Joseph M 2456 1881 0.024378\n",
" 2945 Henry M 2339 1881 0.023217\n",
" 2946 Thomas M 2282 1881 0.022651\n",
" 2947 Edward M 2177 1881 0.021609\n",
"1882 F 3935 Mary F 8149 1882 0.075558\n",
" 3936 Anna F 3143 1882 0.029142\n",
" 3937 Emma F 2303 1882 0.021354\n",
" 3938 Elizabeth F 2187 1882 0.020278\n",
" 3939 Minnie F 2004 1882 0.018581\n",
" 3940 Margaret F 1821 1882 0.016884\n",
" 3941 Ida F 1673 1882 0.015512\n",
" 3942 Alice F 1542 1882 0.014298\n",
" 3943 Bertha F 1508 1882 0.013982\n",
" 3944 Annie F 1492 1882 0.013834"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def get_top(group, topNumber):\n",
" return group.sort_values(by='births', ascending=False)[:topNumber]\n",
"\n",
"grouped = names.groupby(['year', 'sex'])\n",
"topNames = grouped.apply(get_top, topNumber=10)\n",
"# rename indexes to avoid warning; index and columns should have different names\n",
"topNames.index.rename(['year_', 'sex_', None], inplace=True)\n",
"topNames[:50]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is our concluding example and we want to measure the increasing in name diversity."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"(function(root) {\n",
" function embed_document(root) {\n",
" \n",
" var docs_json = {\"7bb694d8-983c-46d5-8c14-a77c01b8e79d\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"0c30b247-6784-44dc-be0a-fb275a26fb20\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"a4b286bb-db3c-4487-a649-8bb76c0db832\",\"type\":\"LinearAxis\"}],\"plot_height\":300,\"plot_width\":750,\"renderers\":[{\"id\":\"0c30b247-6784-44dc-be0a-fb275a26fb20\",\"type\":\"LinearAxis\"},{\"id\":\"4907f1d8-bf46-481c-998d-f6983014dfac\",\"type\":\"Grid\"},{\"id\":\"a4b286bb-db3c-4487-a649-8bb76c0db832\",\"type\":\"LinearAxis\"},{\"id\":\"3bbda2b3-cc64-4968-a71d-3b0495f2217a\",\"type\":\"Grid\"},{\"id\":\"a49d7356-92ba-408d-bac8-5791100ec80d\",\"type\":\"BoxAnnotation\"},{\"id\":\"352be58b-f19e-427f-9468-97d6eb0b3591\",\"type\":\"Legend\"},{\"id\":\"49626e97-d48b-4ede-99f2-57f24c5b0780\",\"type\":\"GlyphRenderer\"},{\"id\":\"6d22efa0-0aa9-4104-9f5e-950a4511511a\",\"type\":\"GlyphRenderer\"}],\"title\":null,\"toolbar\":{\"id\":\"597cb497-c2e7-41c1-9ff9-b3935de81c02\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"6bd76e99-e34b-499e-81ff-a157f6805f71\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"7b6ceb73-1b9c-4236-b078-b416d154bbcb\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"cf679e31-541e-49ab-b595-38798fa69cd5\",\"type\":\"Range1d\"},\"y_scale\":{\"id\":\"6fe52028-77e1-4373-a44f-25f2fcd65f5c\",\"type\":\"LinearScale\"}},\"id\":\"650d1257-2c0a-4e94-8b1b-5dba09d530a8\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"34cae77b-4086-45e2-a3e0-d21bc2b608cd\",\"type\":\"PanTool\"},{\"id\":\"8607acd0-3c87-4c34-a225-e5a6d11b6e5c\",\"type\":\"WheelZoomTool\"},{\"id\":\"24cd6b65-9f8a-413c-af1a-719871297094\",\"type\":\"BoxZoomTool\"},{\"id\":\"3740e5a9-60c6-4717-a52c-f71ea7bee7e5\",\"type\":\"SaveTool\"},{\"id\":\"6175539b-4c74-4a7c-a209-589f2c7e1e7b\",\"type\":\"ResetTool\"},{\"id\":\"0bf37219-6e76-49eb-ac67-d105b2084e11\",\"type\":\"HelpTool\"}]},\"id\":\"597cb497-c2e7-41c1-9ff9-b3935de81c02\",\"type\":\"Toolbar\"},{\"attributes\":{\"data_source\":{\"id\":\"33378711-54c4-4c11-9227-93247c90e020\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"11170d13-02c9-4c49-ac7a-258314dd2d5b\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"f0c58567-412f-42d4-93e3-0c4a9f2c29bd\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"a016fd95-7f23-43c9-8d65-770ca7f7067f\",\"type\":\"CDSView\"}},\"id\":\"49626e97-d48b-4ede-99f2-57f24c5b0780\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"650d1257-2c0a-4e94-8b1b-5dba09d530a8\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4fc071fc-b7a5-48de-81b0-d29386cda69b\",\"type\":\"BasicTicker\"}},\"id\":\"3bbda2b3-cc64-4968-a71d-3b0495f2217a\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":{\"__ndarray__\":\"sERZv/GMzz/Jai6l2erOP59+4Opopc4/66wSX+f6zT9byy0U3Z/NP5H7W0vk/sw/fnPTl2drzD9P42qM5AzMP67U6YiqVss/BlAHJ/kcyz8xozvyzY7KP6Uzh7J6hco/nh4aEXVpyj9GGvU035rKP6nQUZwS1sk/hfXuLfrtyT+iXOg6jPjJP8BCk0Akxck/sqg16AujyT+PkU+r38rJP8L8LXMK8Mg/xixpGn8cyT+4xTPHGEzJP+0DX+kScck/4nCVmg6PyT98iUajx4PJP2H0+mMSTso/SCRinQURyj9PTOO2bK/KPzB7PNWn9co/XOK7MFryyj+cmuBrUAvMP5mtXp0fdsw/YS6L/xb+zD8Uhc95hk3NP8qGdHtvqc0/Sp2OWZyfzT+TO/QeOsvNP2DZ4+8rzs0/Z/Zpuv9vzT9qIAUzXsHNPzSQoL6L8s0/8ZXn1QvOzT8AW4DiCPzNPxZs9q0o0c0/lB1nbbtrzT8YGcvoLdPMP7ewII5ktcw/rSOItU+hzD/MC46JkoDMPyaGUp1AiMw/cmDOK79BzT+KtI2M4WDNP6uThUbNO80/sq5mzTz3zT+fbxSv5qjPP37Y3lbF9M4//x/dRisxzj9F7IyrKMbNP502Lfl3fM0/3A2w3V6MzT9G5An98RXOP+3F5TsVts4/gat/hixFzz+uooJC+/vOP6ZHnNQ7hc4/IYRjVt1Ozz+H0ckSU3jQP+ISs1b4TdA/tXR4kcGqzz9ewTXb59fOP4goDfTVsM4/JWyO92i2zT8LWiE9/JPNPx2VtTRPds0/SSWQAYaGzD+psaEsZXHLP7ACa7bvv8k/Cah6xbbHxz+opbWaPOPGP2UcxA8Lt8U/eIPCgmTUxD8wBdQBS2nEP0fS/aeDkMQ/+cCkxwzvwz+3p/lWcInEP8/0h8Aya8Q/bP982sAuxD+EaQFnGqnEP6AmSKcmYMQ/IqDhwvjTxD8/N0ZKg3zFP4zOd8m2hMY/ll7R99eYxj+k537gu8TGP0fr8ZzfP8Y/vzplKlAExj+kATN+12vFP4NmqSj8LMU/tR8jy3DFxT//vtv/ueTFPw1y5/yfMcY/G521zaUWxj9gX2tAezLHP5vhd160Hsc/lNbhJfYOxz9CKwsR+CnHP5HXgHlVQMc/AWqUGV8kxj9nlgjVTpXFP1xirMFLb8Q/kv/c08Qcwz+NyRi5iKfBP2ms7CYR+sA/F234PxUEwD8wA5jku1i+P4at49XrXb0/YuFxcxHmvD9YmlnaCZC8P3RMXbqyfLs/lZ2M+pMpuj/u+Of2LRG5P0SK/5sig7g/Vs6ewjWhuD+2apDN/+C3P6/z5CsWALc/XMahxiNetj/9BVsuVW+2P1pXcWPB0rU/M8jeIkcntj8ujHpGR7a2P0Y+k8aMuLY/\",\"dtype\":\"float64\",\"shape\":[132]}}},\"id\":\"33378711-54c4-4c11-9227-93247c90e020\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"970479f5-a221-42b7-a134-64234a38004e\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"312cfea8-3f4b-4a68-a95d-ff24894b5bcf\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"926e7979-f9c4-48a3-9fa7-b7630881d312\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"57fa4b62-936c-44b5-a7cf-57edc460065e\",\"type\":\"CDSView\"}},\"id\":\"6d22efa0-0aa9-4104-9f5e-950a4511511a\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"label\":{\"value\":\"F\"},\"renderers\":[{\"id\":\"49626e97-d48b-4ede-99f2-57f24c5b0780\",\"type\":\"GlyphRenderer\"}]},\"id\":\"1f12895a-08f4-499d-9b46-18997ee12bee\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"34cae77b-4086-45e2-a3e0-d21bc2b608cd\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"abfa4cf1-06d7-438c-ae2a-fbfd4d8ff75a\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"formatter\":{\"id\":\"437ba47b-0eba-4954-8536-90ed014683bd\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"650d1257-2c0a-4e94-8b1b-5dba09d530a8\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"4fc071fc-b7a5-48de-81b0-d29386cda69b\",\"type\":\"BasicTicker\"}},\"id\":\"a4b286bb-db3c-4487-a649-8bb76c0db832\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"970479f5-a221-42b7-a134-64234a38004e\",\"type\":\"ColumnDataSource\"}},\"id\":\"57fa4b62-936c-44b5-a7cf-57edc460065e\",\"type\":\"CDSView\"},{\"attributes\":{\"items\":[{\"id\":\"1f12895a-08f4-499d-9b46-18997ee12bee\",\"type\":\"LegendItem\"},{\"id\":\"084581b7-82b4-4c35-90a8-42d9316cf7e2\",\"type\":\"LegendItem\"}],\"plot\":{\"id\":\"650d1257-2c0a-4e94-8b1b-5dba09d530a8\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"352be58b-f19e-427f-9468-97d6eb0b3591\",\"type\":\"Legend\"},{\"attributes\":{\"plot\":{\"id\":\"650d1257-2c0a-4e94-8b1b-5dba09d530a8\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"120b93cf-66d3-4290-936f-45dbfa5abd67\",\"type\":\"BasicTicker\"}},\"id\":\"4907f1d8-bf46-481c-998d-f6983014dfac\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"3740e5a9-60c6-4717-a52c-f71ea7bee7e5\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"437ba47b-0eba-4954-8536-90ed014683bd\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"source\":{\"id\":\"33378711-54c4-4c11-9227-93247c90e020\",\"type\":\"ColumnDataSource\"}},\"id\":\"a016fd95-7f23-43c9-8d65-770ca7f7067f\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"6175539b-4c74-4a7c-a209-589f2c7e1e7b\",\"type\":\"ResetTool\"},{\"attributes\":{\"callback\":null,\"end\":1.2},\"id\":\"cf679e31-541e-49ab-b595-38798fa69cd5\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"8607acd0-3c87-4c34-a225-e5a6d11b6e5c\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"926e7979-f9c4-48a3-9fa7-b7630881d312\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"6fe52028-77e1-4373-a44f-25f2fcd65f5c\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011],\"y\":{\"__ndarray__\":\"/s3L/3lM3D9WtVfhggfcP7NkMHs7V9s/6q8DyydI2z8NNX1CdGLaP7HYENpVCNo/8zbvL/zY2T+bj2Eh6I/ZP/eAqc1LOtk/S4OFxDXp2D99eDGBwo3YP2vTvKHFJNg/SWmXVFar1z9zxadJPJPXP2cnnNw6/NY/A+3Fiw3a1j+2PAPOaIrWP7lb3q0vgdY/9oQ4ETdV1j/mEhyQJvDVPySWyT7y5dU/wMVxeLOB1T9Ml0RzmnzVP+faP8PrQtU/9/QS8KLx1D/EOB2YwY/UP+PLqUO6tNQ/5dqUs7VF1D91wrWWCkrUPwhoHw3tDNQ/yW1XhE/60z+BaiSZWiLUP3de+d/1ktM/97dV85OR0z8ds1QMnbnTP4P0ukf9e9M/28nKo1Cg0z9+1CBux8PTP6Zw0ycc3NM/TqTwa93M0z/zg+oT2zPUP5+M0u9xTdQ/NEAUUkV11D9PDhPl26XUP1dZRdIK5tQ/oe8uHuwR1T+FipexaybVP//PZQBWPNU/otgEiEE41T9ipYbz42vVP70JSyo4lNU/gChVKgOf1T/BVn8twHrVPzecramcZNU/K8Mi31xI1T8HhQnXfEjVP0z7WKuDUdU/TjDibNOB1T9MnJOTXmvVP2LsLWehZNU/mpvetU5q1T+B5mplA33VP6gsFiEIqtU/S+h/HI3X1T8PMEnnV/7VP+/aR2wX9tU/IDVei8lR1j8IpKPaJALWP6sVNabps9U/56ZieLuv1T/BKcqZDKHVPwKFGJH0n9U/ql8QxfOQ1T8YRut4MUXVP1hFg94d0NQ/cZD57yyT1D+JvVgfxCbUP5+uEnw1stM/y0lptFU50z+YvTblR9fSP6y3W/ysndI/KQCJlc+b0j/wMW+jmmvSPy/Ig6iKZtI/YL1Zv32Q0j+6Z4U5wybSP9iuxZsaCtI/RdAakHIY0j+JxlOKeyDSP5il4ytIudE/BFV+xTgv0T/N1LZRXPfQP6d0V4aE+9A/CHBNmeP00D+aku8ryvzQP5J21FMacNA/YXg+JMcg0D8C+/E89O7PP3pBANjCh88/JeKNqyzdzj9hjnk8DjPOPzbmJaBRM84/F9z4ZzmRzj8YArtD+WXOP7lBnso8DM4/i2KWQg8izT/XqRzsYGjMP703iPnx+cs/muMKVghiyz+7pASEmCfKP/mf49aB8Mg/GDqvu+qPxz8LECLHwyvGP2h5/tAsXsU/wKaZapDpxD+NRLKSVKDEP8OXpojF3cM/Kpua59GUwz8fIStOs8XCP01qXUn6C8I/VWmGFdcdwT/qeAGrej/APxIQo0nrtb8/7UpYwaoqvj9m4O/v4RK9PxK8z1jPfbs/x3H6t9X6uT+7rHVxgyq5P3p0IQpWMLg/27h8OeiGtz+7OcBFtO+2P4EwUYznFLc/\",\"dtype\":\"float64\",\"shape\":[132]}}},\"id\":\"970479f5-a221-42b7-a134-64234a38004e\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"4fc071fc-b7a5-48de-81b0-d29386cda69b\",\"type\":\"BasicTicker\"},{\"attributes\":{\"line_color\":\"green\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"11170d13-02c9-4c49-ac7a-258314dd2d5b\",\"type\":\"Line\"},{\"attributes\":{\"line_color\":\"blue\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"312cfea8-3f4b-4a68-a95d-ff24894b5bcf\",\"type\":\"Line\"},{\"attributes\":{\"formatter\":{\"id\":\"abfa4cf1-06d7-438c-ae2a-fbfd4d8ff75a\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"650d1257-2c0a-4e94-8b1b-5dba09d530a8\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"120b93cf-66d3-4290-936f-45dbfa5abd67\",\"type\":\"BasicTicker\"}},\"id\":\"0c30b247-6784-44dc-be0a-fb275a26fb20\",\"type\":\"LinearAxis\"},{\"attributes\":{\"line_alpha\":0.1,\"line_color\":\"#1f77b4\",\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"f0c58567-412f-42d4-93e3-0c4a9f2c29bd\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"120b93cf-66d3-4290-936f-45dbfa5abd67\",\"type\":\"BasicTicker\"},{\"attributes\":{\"label\":{\"value\":\"M\"},\"renderers\":[{\"id\":\"6d22efa0-0aa9-4104-9f5e-950a4511511a\",\"type\":\"GlyphRenderer\"}]},\"id\":\"084581b7-82b4-4c35-90a8-42d9316cf7e2\",\"type\":\"LegendItem\"},{\"attributes\":{\"overlay\":{\"id\":\"a49d7356-92ba-408d-bac8-5791100ec80d\",\"type\":\"BoxAnnotation\"}},\"id\":\"24cd6b65-9f8a-413c-af1a-719871297094\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"callback\":null},\"id\":\"6bd76e99-e34b-499e-81ff-a157f6805f71\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"7b6ceb73-1b9c-4236-b078-b416d154bbcb\",\"type\":\"LinearScale\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"a49d7356-92ba-408d-bac8-5791100ec80d\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"0bf37219-6e76-49eb-ac67-d105b2084e11\",\"type\":\"HelpTool\"}],\"root_ids\":[\"650d1257-2c0a-4e94-8b1b-5dba09d530a8\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.13\"}};\n",
" var render_items = [{\"docid\":\"7bb694d8-983c-46d5-8c14-a77c01b8e79d\",\"elementid\":\"c4e8f538-38f1-439c-a310-c8d76f9c6105\",\"modelid\":\"650d1257-2c0a-4e94-8b1b-5dba09d530a8\"}];\n",
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
"\n",
" }\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" } else {\n",
" var attempts = 0;\n",
" var timer = setInterval(function(root) {\n",
" if (root.Bokeh !== undefined) {\n",
" embed_document(root);\n",
" clearInterval(timer);\n",
" }\n",
" attempts++;\n",
" if (attempts > 100) {\n",
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\")\n",
" clearInterval(timer);\n",
" }\n",
" }, 10, root)\n",
" }\n",
"})(window);"
],
"application/vnd.bokehjs_exec.v0+json": ""
},
"metadata": {
"application/vnd.bokehjs_exec.v0+json": {
"id": "650d1257-2c0a-4e94-8b1b-5dba09d530a8"
}
},
"output_type": "display_data"
}
],
"source": [
"from bokeh.models.ranges import Range1d\n",
"\n",
"diversity = topNames.pivot_table('prop', index='year', columns='sex', aggfunc=sum)\n",
"\n",
"fig = bk.figure(plot_width=750, plot_height=300, title=None)\n",
"fig.line(x=diversity.index, y=diversity['F'], line_color='green', legend='F')\n",
"fig.line(x=diversity.index, y=diversity['M'], line_color='blue', legend='M')\n",
"fig.y_range = Range1d(0, 1.2)\n",
"bk.show(fig)\n",
"\n",
"# Or, using directly Pandas' \"plot\" method (which calls Matplotlib, not Bokeh)\n",
"# diversity.plot(title='Sum of diversity.prop by year and sex',\n",
"# yticks=np.linspace(0, 1.2, 13), xticks=range(1880, 2020, 10))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"\n",
"Visit [www.add-for.com]() for more tutorials and updates.\n",
"\n",
"This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:addfor_tutorials]",
"language": "python",
"name": "conda-env-addfor_tutorials-py"
},
"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.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}