Skip to content

Instantly share code, notes, and snippets.

@tonyfast
Last active August 29, 2015 14:27
Show Gist options
  • Save tonyfast/3061f9968936ea850072 to your computer and use it in GitHub Desktop.
Save tonyfast/3061f9968936ea850072 to your computer and use it in GitHub Desktop.
Building Interactions between the IPython notebook and Bokeh Plots
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exploring Bokeh Callbacks\n",
"\n",
"* Dynamically update a table from a Bokeh selection"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
" \n",
" <link rel=\"stylesheet\" href=\"http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.css\" type=\"text/css\" />\n",
" <script type=\"text/javascript\" src=\"http://cdn.pydata.org/bokeh/release/bokeh-0.9.1.min.js\"></script>\n",
" <script type=\"text/javascript\">\n",
" Bokeh.set_log_level(\"info\");\n",
" </script>\n",
" <div>\n",
" <a href=\"http://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
" <span>BokehJS successfully loaded.</span>\n",
" </div>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from coffeetools import coffee\n",
"from IPython.display import HTML\n",
"\n",
"from bokeh.plotting import figure, output_notebook, show\n",
"from bokeh.models import ColumnDataSource, Circle, HoverTool, Callback\n",
"from bokeh.resources import CDN\n",
"from bokeh.sampledata.glucose import data\n",
"\n",
"output_notebook(\n",
" resources = CDN\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Load in d3js because I know how to use it and use momentjs to change time on the client."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js\" charset=\"utf-8\">\n",
" </script>\n",
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js\">\n",
" </script>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"HTML(\"\"\"\n",
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js\" charset=\"utf-8\">\n",
" </script>\n",
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js\">\n",
" </script>\n",
"\"\"\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Define our dataframe and columnDataSource"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"df = data.ix['2010-10-06'].reset_index()\n",
"source = ColumnDataSource( df )"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Set up the plot from the interactions example"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Basic plot setup\n",
"p = figure(\n",
" width=600, height=300, \n",
" x_axis_type=\"datetime\", \n",
" tools=\"\", toolbar_location=None, \n",
" title='Hover over points'\n",
")\n",
"\n",
"p.line(\n",
" x = 'datetime', \n",
" y = 'glucose', \n",
" line_dash=\"4 4\", \n",
" line_width=1, \n",
" color='gray',\n",
" source = source\n",
")\n",
"\n",
"# Add a circle, that is visible only when selected\n",
"invisible_circle = Circle(\n",
" x='datetime', \n",
" y='glucose', \n",
" fill_color='gray', \n",
" fill_alpha=0.05, \n",
" line_color=None, \n",
" size=20\n",
")\n",
"visible_circle = Circle(\n",
" x='datetime', \n",
" y='glucose', \n",
" fill_color='firebrick', \n",
" fill_alpha=0.5, \n",
" line_color=None, \n",
" size=20\n",
")\n",
"cr = p.add_glyph(\n",
" source, invisible_circle, \n",
" selection_glyph=visible_circle, nonselection_glyph=invisible_circle\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Callback\n",
"\n",
"> Use a pandas data table to interactively visualize a Bokeh data selection. All Javascript is written in coffeescript."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"code = \"\"\"\n",
"source.set 'selected', cb_data['index']\n",
"\"\"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Select an existing pandas DataTable and get the Column Names.\n",
"> Also, pull the source data from Bokeh into the client."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Add a hover tool, that selects the circle\n",
"code += \"\"\"\n",
"table = d3.select 'table.dataframe > tbody'\n",
"\n",
"keys = d3.selectAll('table.dataframe > thead th')[0]\n",
" .map (node)->\n",
" k = node.innerText\n",
"keys[0] = 'index'\n",
"\n",
"data = source.get('data')\n",
"\"\"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> [d3 enter, exit, update patten](https://medium.com/@c_behrens/enter-update-exit-6cafc6014c36)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"code += \"\"\" \n",
"s = table.selectAll 'tr'\n",
" .data cb_data['index']['1d']['indices'] \n",
" \n",
"s.enter().append 'tr'\n",
" .each (d,i)->\n",
" _s = d3.select @\n",
" _s.append 'th'\n",
" [1..(keys.length-1)].forEach ()->\n",
" _s.append 'td'\n",
"s.exit().remove()\n",
"\n",
"table.selectAll 'tr'\n",
" .each (i) ->\n",
" d3.select @\n",
" .selectAll 'th,td'\n",
" .each (d,ki)->\n",
" v = data[ keys[ki] ][i]\n",
" if keys[ki] in ['datetime']\n",
" v = moment(v).format('hh:mm')\n",
" @.innerText = v\n",
"\n",
"\"\"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Compile CoffeeScript as a bare function"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"code = coffee.compile( \n",
" code, \n",
" bare= True\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"> Create the Bokeh plot"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<script type=\"text/javascript\">\n",
" Bokeh.$(function() {\n",
" var all_models = [{\"type\": \"Grid\", \"id\": \"e02cd502-1eb7-416c-8c62-fcc68adeb1e3\", \"attributes\": {\"plot\": {\"type\": \"Plot\", \"id\": \"0fde0414-7c0a-4a79-96a8-40edc25397e2\", \"subtype\": \"Figure\"}, \"tags\": [], \"id\": \"e02cd502-1eb7-416c-8c62-fcc68adeb1e3\", \"doc\": null, \"dimension\": 1, \"ticker\": {\"type\": \"BasicTicker\", \"id\": \"65dbc853-c858-473f-b0d1-3e9bee210747\"}}}, {\"type\": \"LinearAxis\", \"id\": \"667f01f9-8c26-4789-a7da-7f3954b42254\", \"attributes\": {\"plot\": {\"type\": \"Plot\", \"id\": \"0fde0414-7c0a-4a79-96a8-40edc25397e2\", \"subtype\": \"Figure\"}, \"tags\": [], \"id\": \"667f01f9-8c26-4789-a7da-7f3954b42254\", \"doc\": null, \"formatter\": {\"type\": \"BasicTickFormatter\", \"id\": \"98b5123c-71a0-41e1-aebf-703430ebf337\"}, \"ticker\": {\"type\": \"BasicTicker\", \"id\": \"65dbc853-c858-473f-b0d1-3e9bee210747\"}}}, {\"type\": \"BasicTicker\", \"id\": \"65dbc853-c858-473f-b0d1-3e9bee210747\", \"attributes\": {\"tags\": [], \"doc\": null, \"id\": \"65dbc853-c858-473f-b0d1-3e9bee210747\", \"mantissas\": [2, 5, 10], \"num_minor_ticks\": 5}}, {\"type\": \"Grid\", \"id\": \"9d372810-a210-4bbf-8142-f7813489c157\", \"attributes\": {\"plot\": {\"type\": \"Plot\", \"id\": \"0fde0414-7c0a-4a79-96a8-40edc25397e2\", \"subtype\": \"Figure\"}, \"tags\": [], \"id\": \"9d372810-a210-4bbf-8142-f7813489c157\", \"doc\": null, \"dimension\": 0, \"ticker\": {\"type\": \"DatetimeTicker\", \"id\": \"429f4ade-d381-43c2-92a0-cfe6d55ebed1\"}}}, {\"type\": \"Circle\", \"id\": \"d90692e4-1a50-4825-a0d5-9c7cb81836f7\", \"attributes\": {\"tags\": [], \"x\": {\"field\": \"datetime\"}, \"line_color\": null, \"fill_color\": {\"value\": \"gray\"}, \"id\": \"d90692e4-1a50-4825-a0d5-9c7cb81836f7\", \"size\": {\"units\": \"screen\", \"value\": 20}, \"y\": {\"field\": \"glucose\"}, \"doc\": null, \"fill_alpha\": {\"value\": 0.05}}}, {\"type\": \"Line\", \"id\": \"cb04816a-11af-46c7-b157-e3706de8bba6\", \"attributes\": {\"tags\": [], \"x\": {\"field\": \"datetime\"}, \"line_color\": {\"value\": \"gray\"}, \"line_dash\": [4, 4], \"line_alpha\": {\"value\": 1.0}, \"id\": \"cb04816a-11af-46c7-b157-e3706de8bba6\", \"doc\": null, \"y\": {\"field\": \"glucose\"}, \"line_width\": {\"value\": 1}}}, {\"type\": \"DataRange1d\", \"id\": \"b3a1ab94-4fdb-4a8d-ac95-ec7fa612a80b\", \"attributes\": {\"tags\": [], \"doc\": null, \"callback\": null, \"id\": \"b3a1ab94-4fdb-4a8d-ac95-ec7fa612a80b\", \"renderers\": [], \"names\": []}}, {\"type\": \"ColumnDataSource\", \"id\": \"75c7cfc9-8bba-468d-b6ec-4893e22b5dc1\", \"attributes\": {\"tags\": [], \"doc\": null, \"callback\": null, \"data\": {\"isig\": [\"20.12\", \"20.84\", \"20.88\", \"20.9\", \"20.84\", \"20.92\", \"21.44\", \"21.3\", \"20.3\", \"20.44\", \"19.88\", \"19.08\", \"19.02\", \"18.98\", \"18.6\", \"18.48\", \"18.52\", \"18.52\", \"18.52\", \"18.66\", \"18.88\", \"19.2\", \"19.5\", \"19.64\", \"20.02\", \"20.16\", \"20.12\", \"20.08\", \"20.02\", \"19.72\", \"19.42\", \"19.2\", \"18.9\", \"19.2\", \"19.2\", \"18.84\", \"18.62\", \"18.44\", \"18.3\", \"18.18\", \"18.04\", \"18.04\", \"17.92\", \"17.66\", \"17.46\", \"16.92\", \"16.46\", \"16.24\", \"16.28\", \"16.22\", \"16.18\", \"16.04\", \"15.88\", \"15.76\", \"15.68\", \"15.7\", \"15.92\", \"15.86\", \"15.52\", \"15.34\", \"15.36\", \"15.38\", \"15.48\", \"15.32\", \"15.02\", \"14.64\", \"14.34\", \"14.08\", \"13.8\", \"13.74\", \"13.7\", \"13.66\", \"13.66\", \"13.44\", \"13.34\", \"13.72\", \"14.04\", \"14.14\", \"14.3\", \"14.52\", \"14.86\", \"15.44\", \"15.72\", \"15.62\", \"15.46\", \"15.34\", \"15.22\", \"15.1\", \"14.28\", \"14.14\", \"14.6\", \"14.5\", \"13.88\", \"13.1\", \"12.88\", \"12.92\", \"13.4\", \"15.4\", \"17.42\", \"19.82\", \"22.18\", \"24.06\", \"25.72\", \"27.12\", \"28.52\", \"29.36\", \"29.34\", \"30.08\", \"31.08\", \"32.3\", \"33.48\", \"34.18\", \"35.28\", \"36.04\", \"36.68\", \"37.36\", \"37.42\", \"37.6\", \"37.68\", \"37.48\", \"37.26\", \"36.64\", \"36.16\", \"35.52\", \"34.88\", \"34.62\", \"34.06\", \"33.62\", \"33.52\", \"32.78\", \"32.14\", \"31.7\", \"31.1\", \"30.72\", \"30.44\", \"29.82\", \"29.28\", \"28.72\", \"28.24\", \"27.7\", \"27.12\", \"26.54\", \"26\", \"25.66\", \"24.88\", \"24.44\", \"23.7\", \"22.66\", \"22.48\", \"22.06\", \"21.62\", \"21.02\", \"20.3\", \"20.26\", \"22.5\", \"26\", \"29.9\", \"33.88\", \"36.46\", \"38.06\", \"38.82\", \"38.86\", \"38.58\", \"39.36\", \"40\", \"40.56\", \"41.12\", \"40.86\", \"40.88\", \"40.4\", \"39.32\", \"38.22\", \"36.74\", \"33.86\", \"30.66\", \"28.34\", \"27.58\", \"26.92\", \"26.2\", \"25.28\", \"24.36\", \"23.98\", \"22.88\", \"21.42\", \"20.06\", \"19.54\", \"19.58\", \"19.26\", \"18.28\", \"16.54\", \"16\", \"15.42\", \"15.74\", \"15.66\", \"14.66\", \"13.38\", \"12.56\", \"11.74\", \"11.3\", \"11.04\", \"10.78\", \"10.48\", \"10.2\", \"10.16\", \"10.14\", \"10.2\", \"10.58\", \"10.92\", \"10.88\", \"10.64\", \"10.4\", \"10.44\", \"10.22\", \"10.16\", \"10.24\", \"10.14\", \"9.98\", \"10.36\", \"10.78\", \"11.14\", \"11.76\", \"11.88\", \"12.06\", \"12.38\", \"12.04\", \"12.04\", \"12.22\", \"12.18\", \"12.32\", \"12.74\", \"13.22\", \"13.72\", \"14.08\", \"14.08\", \"14.06\", \"13.88\", \"13.8\", \"13.84\", \"13.6\", \"13.84\", \"14.1\", \"14.02\", \"13.78\", \"13.44\", \"12.84\", \"13.26\", \"13.5\", \"14.6\", \"16.94\", \"19.16\", \"20.7\", \"22.82\", \"24.1\", \"25.12\", \"26.54\", \"27.2\", \"28.76\", \"31.72\", \"33.18\", \"33.32\", \"33.3\", \"34.56\", \"34.14\", \"33.22\", \"31.48\", \"30.68\", \"29.64\", \"27.84\", \"27.12\", \"26.5\", \"25.98\", \"25.58\", \"25.92\", \"26.12\", \"25.54\", \"25.12\", \"24.72\", \"24.44\", \"23.12\", \"21.12\", \"22.4\", \"22.84\", \"22.78\", \"22.64\", \"22.08\", \"21.88\", \"21.98\", \"22.16\"], \"glucose\": [143, 147, 150, 152, 152, 152, 154, 155, 142, 140, 138, 134, 131, 130, 128, 127, 126, 126, 126, 126, 127, 129, 131, 132, 134, 136, 136, 136, 136, 135, 134, 132, 130, 130, 130, 129, 128, 127, 125, 124, 123, 123, 122, 121, 120, 118, 115, 112, 111, 111, 110, 110, 109, 108, 107, 107, 107, 108, 107, 105, 105, 105, 105, 104, 103, 102, 99, 97, 96, 94, 94, 93, 93, 92, 91, 92, 94, 95, 96, 97, 99, 102, 104, 112, 112, 112, 111, 110, 107, 104, 105, 105, 103, 99, 96, 94, 95, 102, 114, 128, 144, 160, 173, 185, 196, 205, 209, 214, 219, 226, 234, 241, 248, 255, 260, 265, 268, 270, 272, 271, 271, 268, 265, 261, 256, 253, 250, 246, 244, 241, 237, 233, 229, 225, 222, 204, 200, 197, 193, 190, 186, 182, 179, 175, 171, 168, 164, 158, 154, 151, 148, 145, 141, 133, 139, 152, 173, 196, 217, 233, 244, 249, 250, 253, 256, 260, 263, 265, 265, 264, 260, 254, 246, 234, 217, 200, 188, 181, 175, 169, 164, 159, 154, 147, 138, 132, 129, 127, 123, 117, 111, 106, 104, 103, 100, 94, 88, 83, 78, 75, 73, 71, 69, 68, 67, 67, 68, 70, 71, 71, 70, 69, 68, 67, 67, 67, 66, 67, 69, 71, 74, 76, 78, 80, 80, 80, 80, 80, 80, 82, 84, 87, 90, 92, 87, 87, 86, 86, 86, 86, 87, 87, 87, 85, 83, 82, 83, 87, 95, 107, 118, 130, 141, 149, 172, 179, 187, 201, 214, 221, 225, 230, 232, 230, 223, 216, 208, 199, 191, 185, 181, 177, 176, 177, 176, 173, 171, 169, 163, 154, 152, 153, 154, 154, 153, 151, 150, 150], \"index\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287], \"datetime\": [1286323380000.0, 1286323680000.0, 1286323980000.0, 1286324280000.0, 1286324580000.0, 1286324880000.0, 1286325180000.0, 1286325480000.0, 1286325780000.0, 1286326080000.0, 1286326380000.0, 1286326680000.0, 1286326980000.0, 1286327280000.0, 1286327580000.0, 1286327880000.0, 1286328180000.0, 1286328480000.0, 1286328780000.0, 1286329080000.0, 1286329380000.0, 1286329680000.0, 1286329980000.0, 1286330280000.0, 1286330580000.0, 1286330880000.0, 1286331180000.0, 1286331480000.0, 1286331780000.0, 1286332080000.0, 1286332380000.0, 1286332680000.0, 1286332980000.0, 1286333280000.0, 1286333580000.0, 1286333880000.0, 1286334180000.0, 1286334480000.0, 1286334780000.0, 1286335080000.0, 1286335380000.0, 1286335680000.0, 1286335980000.0, 1286336280000.0, 1286336580000.0, 1286336880000.0, 1286337180000.0, 1286337480000.0, 1286337780000.0, 1286338080000.0, 1286338380000.0, 1286338680000.0, 1286338980000.0, 1286339280000.0, 1286339580000.0, 1286339880000.0, 1286340180000.0, 1286340480000.0, 1286340780000.0, 1286341080000.0, 1286341380000.0, 1286341680000.0, 1286341980000.0, 1286342280000.0, 1286342580000.0, 1286342880000.0, 1286343180000.0, 1286343480000.0, 1286343780000.0, 1286344080000.0, 1286344380000.0, 1286344680000.0, 1286344980000.0, 1286345280000.0, 1286345580000.0, 1286345880000.0, 1286346180000.0, 1286346480000.0, 1286346780000.0, 1286347080000.0, 1286347380000.0, 1286347680000.0, 1286347980000.0, 1286348280000.0, 1286348580000.0, 1286348880000.0, 1286349180000.0, 1286349480000.0, 1286349780000.0, 1286350080000.0, 1286350380000.0, 1286350680000.0, 1286350980000.0, 1286351280000.0, 1286351580000.0, 1286351880000.0, 1286352180000.0, 1286352480000.0, 1286352780000.0, 1286353080000.0, 1286353380000.0, 1286353680000.0, 1286353980000.0, 1286354280000.0, 1286354580000.0, 1286354880000.0, 1286355180000.0, 1286355480000.0, 1286355780000.0, 1286356080000.0, 1286356380000.0, 1286356680000.0, 1286356980000.0, 1286357280000.0, 1286357580000.0, 1286357880000.0, 1286358180000.0, 1286358480000.0, 1286358780000.0, 1286359080000.0, 1286359380000.0, 1286359680000.0, 1286359980000.0, 1286360280000.0, 1286360580000.0, 1286360880000.0, 1286361180000.0, 1286361480000.0, 1286361780000.0, 1286362080000.0, 1286362380000.0, 1286362680000.0, 1286362980000.0, 1286363280000.0, 1286363580000.0, 1286363880000.0, 1286364180000.0, 1286364480000.0, 1286364780000.0, 1286365080000.0, 1286365380000.0, 1286365680000.0, 1286365980000.0, 1286366280000.0, 1286366580000.0, 1286366880000.0, 1286367180000.0, 1286367480000.0, 1286367780000.0, 1286368080000.0, 1286368380000.0, 1286368680000.0, 1286368980000.0, 1286369280000.0, 1286369580000.0, 1286369880000.0, 1286370180000.0, 1286370480000.0, 1286370780000.0, 1286371080000.0, 1286371380000.0, 1286371680000.0, 1286371980000.0, 1286372280000.0, 1286372580000.0, 1286372880000.0, 1286373180000.0, 1286373480000.0, 1286373780000.0, 1286374080000.0, 1286374380000.0, 1286374680000.0, 1286374980000.0, 1286375280000.0, 1286375580000.0, 1286375880000.0, 1286376180000.0, 1286376480000.0, 1286376780000.0, 1286377080000.0, 1286377380000.0, 1286377680000.0, 1286377980000.0, 1286378280000.0, 1286378580000.0, 1286378880000.0, 1286379180000.0, 1286379480000.0, 1286379780000.0, 1286380080000.0, 1286380380000.0, 1286380680000.0, 1286380980000.0, 1286381280000.0, 1286381580000.0, 1286381880000.0, 1286382180000.0, 1286382480000.0, 1286382780000.0, 1286383080000.0, 1286383380000.0, 1286383680000.0, 1286383980000.0, 1286384280000.0, 1286384580000.0, 1286384880000.0, 1286385180000.0, 1286385480000.0, 1286385780000.0, 1286386080000.0, 1286386380000.0, 1286386680000.0, 1286386980000.0, 1286387280000.0, 1286387580000.0, 1286387880000.0, 1286388180000.0, 1286388480000.0, 1286388780000.0, 1286389080000.0, 1286389380000.0, 1286389680000.0, 1286389980000.0, 1286390280000.0, 1286390580000.0, 1286390880000.0, 1286391180000.0, 1286391480000.0, 1286391780000.0, 1286392080000.0, 1286392380000.0, 1286392680000.0, 1286392980000.0, 1286393280000.0, 1286393580000.0, 1286393880000.0, 1286394180000.0, 1286394480000.0, 1286394780000.0, 1286395080000.0, 1286395380000.0, 1286395680000.0, 1286395980000.0, 1286396280000.0, 1286396580000.0, 1286396880000.0, 1286397180000.0, 1286397480000.0, 1286397780000.0, 1286398080000.0, 1286398380000.0, 1286398680000.0, 1286398980000.0, 1286399280000.0, 1286399580000.0, 1286399880000.0, 1286400180000.0, 1286400480000.0, 1286400780000.0, 1286401080000.0, 1286401380000.0, 1286401680000.0, 1286401980000.0, 1286402280000.0, 1286402580000.0, 1286402880000.0, 1286403180000.0, 1286403480000.0, 1286403780000.0, 1286404080000.0, 1286404380000.0, 1286404680000.0, 1286404980000.0, 1286405280000.0, 1286405580000.0, 1286405880000.0, 1286406180000.0, 1286406480000.0, 1286406780000.0, 1286407080000.0, 1286407380000.0, 1286407680000.0, 1286407980000.0, 1286408280000.0, 1286408580000.0, 1286408880000.0, 1286409180000.0, 1286409480000.0]}, \"selected\": {\"2d\": {\"indices\": []}, \"0d\": {\"indices\": [], \"flag\": false}, \"1d\": {\"indices\": []}}, \"column_names\": [\"isig\", \"glucose\", \"index\", \"datetime\"], \"id\": \"75c7cfc9-8bba-468d-b6ec-4893e22b5dc1\"}}, {\"type\": \"Callback\", \"id\": \"e817fa32-3b6e-48de-9e42-75209daf4fc1\", \"attributes\": {\"tags\": [], \"code\": \"// Generated by CoffeeScript 1.9.3\\nvar data, keys, s, table;\\n\\nsource.set('selected', cb_data['index']);\\n\\ntable = d3.select('table.dataframe > tbody');\\n\\nkeys = d3.selectAll('table.dataframe > thead th')[0].map(function(node) {\\n var k;\\n return k = node.innerText;\\n});\\n\\nkeys[0] = 'index';\\n\\ndata = source.get('data');\\n\\ns = table.selectAll('tr').data(cb_data['index']['1d']['indices']);\\n\\ns.enter().append('tr').each(function(d, i) {\\n var _s, j, ref, results;\\n _s = d3.select(this);\\n _s.append('th');\\n return (function() {\\n results = [];\\n for (var j = 1, ref = keys.length - 1; 1 <= ref ? j <= ref : j >= ref; 1 <= ref ? j++ : j--){ results.push(j); }\\n return results;\\n }).apply(this).forEach(function() {\\n return _s.append('td');\\n });\\n});\\n\\ns.exit().remove();\\n\\ntable.selectAll('tr').each(function(i) {\\n return d3.select(this).selectAll('th,td').each(function(d, ki) {\\n var ref, v;\\n v = data[keys[ki]][i];\\n if ((ref = keys[ki]) === 'datetime') {\\n v = moment(v).format('hh:mm');\\n }\\n return this.innerText = v;\\n });\\n});\\n\", \"id\": \"e817fa32-3b6e-48de-9e42-75209daf4fc1\", \"args\": {\"source\": {\"type\": \"ColumnDataSource\", \"id\": \"75c7cfc9-8bba-468d-b6ec-4893e22b5dc1\"}}, \"doc\": null}}, {\"type\": \"HoverTool\", \"id\": \"c2f5ee2a-3a6f-4f67-bfbf-528680c73cde\", \"attributes\": {\"tags\": [], \"plot\": {\"type\": \"Plot\", \"id\": \"0fde0414-7c0a-4a79-96a8-40edc25397e2\", \"subtype\": \"Figure\"}, \"callback\": {\"type\": \"Callback\", \"id\": \"e817fa32-3b6e-48de-9e42-75209daf4fc1\"}, \"id\": \"c2f5ee2a-3a6f-4f67-bfbf-528680c73cde\", \"doc\": null, \"mode\": \"hline\", \"renderers\": [{\"type\": \"GlyphRenderer\", \"id\": \"fefe5610-2d26-44af-937d-0423eada45e4\"}], \"tooltips\": null, \"names\": []}}, {\"type\": \"DatetimeTicker\", \"id\": \"429f4ade-d381-43c2-92a0-cfe6d55ebed1\", \"attributes\": {\"tags\": [], \"doc\": null, \"num_minor_ticks\": 5, \"id\": \"429f4ade-d381-43c2-92a0-cfe6d55ebed1\"}}, {\"type\": \"ToolEvents\", \"id\": \"a327353d-12ce-432e-a4fe-d41aa6186a17\", \"attributes\": {\"tags\": [], \"doc\": null, \"geometries\": [], \"id\": \"a327353d-12ce-432e-a4fe-d41aa6186a17\"}}, {\"attributes\": {\"tags\": [], \"extra_x_ranges\": {}, \"left\": [{\"type\": \"LinearAxis\", \"id\": \"667f01f9-8c26-4789-a7da-7f3954b42254\"}], \"below\": [{\"type\": \"DatetimeAxis\", \"id\": \"b4da3c40-caaa-4b98-ad61-d527525dbb97\"}], \"plot_height\": 300, \"tool_events\": {\"type\": \"ToolEvents\", \"id\": \"a327353d-12ce-432e-a4fe-d41aa6186a17\"}, \"renderers\": [{\"type\": \"DatetimeAxis\", \"id\": \"b4da3c40-caaa-4b98-ad61-d527525dbb97\"}, {\"type\": \"Grid\", \"id\": \"9d372810-a210-4bbf-8142-f7813489c157\"}, {\"type\": \"LinearAxis\", \"id\": \"667f01f9-8c26-4789-a7da-7f3954b42254\"}, {\"type\": \"Grid\", \"id\": \"e02cd502-1eb7-416c-8c62-fcc68adeb1e3\"}, {\"type\": \"GlyphRenderer\", \"id\": \"7520df03-99f5-4d1e-8481-67cae7bd9d7d\"}, {\"type\": \"GlyphRenderer\", \"id\": \"fefe5610-2d26-44af-937d-0423eada45e4\"}], \"right\": [], \"y_range\": {\"type\": \"DataRange1d\", \"id\": \"b3a1ab94-4fdb-4a8d-ac95-ec7fa612a80b\"}, \"plot_width\": 600, \"doc\": null, \"toolbar_location\": null, \"x_range\": {\"type\": \"DataRange1d\", \"id\": \"d3e69d8d-53e6-4445-affb-136260a5dd77\"}, \"above\": [], \"tools\": [{\"type\": \"HoverTool\", \"id\": \"c2f5ee2a-3a6f-4f67-bfbf-528680c73cde\"}], \"id\": \"0fde0414-7c0a-4a79-96a8-40edc25397e2\", \"title\": \"Hover over points\", \"extra_y_ranges\": {}}, \"type\": \"Plot\", \"id\": \"0fde0414-7c0a-4a79-96a8-40edc25397e2\", \"subtype\": \"Figure\"}, {\"type\": \"DatetimeTickFormatter\", \"id\": \"61a589c0-a828-443b-bd7b-98f0d8a9d440\", \"attributes\": {\"tags\": [], \"doc\": null, \"id\": \"61a589c0-a828-443b-bd7b-98f0d8a9d440\", \"formats\": {}}}, {\"type\": \"DataRange1d\", \"id\": \"d3e69d8d-53e6-4445-affb-136260a5dd77\", \"attributes\": {\"tags\": [], \"doc\": null, \"callback\": null, \"id\": \"d3e69d8d-53e6-4445-affb-136260a5dd77\", \"renderers\": [], \"names\": []}}, {\"type\": \"Line\", \"id\": \"a8a158d9-7db0-432a-a976-5482308b87a4\", \"attributes\": {\"tags\": [], \"x\": {\"field\": \"datetime\"}, \"line_color\": {\"value\": \"#1f77b4\"}, \"line_dash\": [4, 4], \"line_alpha\": {\"value\": 0.1}, \"id\": \"a8a158d9-7db0-432a-a976-5482308b87a4\", \"doc\": null, \"y\": {\"field\": \"glucose\"}, \"line_width\": {\"value\": 1}}}, {\"type\": \"GlyphRenderer\", \"id\": \"7520df03-99f5-4d1e-8481-67cae7bd9d7d\", \"attributes\": {\"nonselection_glyph\": {\"type\": \"Line\", \"id\": \"a8a158d9-7db0-432a-a976-5482308b87a4\"}, \"tags\": [], \"id\": \"7520df03-99f5-4d1e-8481-67cae7bd9d7d\", \"glyph\": {\"type\": \"Line\", \"id\": \"cb04816a-11af-46c7-b157-e3706de8bba6\"}, \"selection_glyph\": null, \"doc\": null, \"data_source\": {\"type\": \"ColumnDataSource\", \"id\": \"75c7cfc9-8bba-468d-b6ec-4893e22b5dc1\"}}}, {\"type\": \"GlyphRenderer\", \"id\": \"fefe5610-2d26-44af-937d-0423eada45e4\", \"attributes\": {\"nonselection_glyph\": {\"type\": \"Circle\", \"id\": \"d90692e4-1a50-4825-a0d5-9c7cb81836f7\"}, \"tags\": [], \"id\": \"fefe5610-2d26-44af-937d-0423eada45e4\", \"glyph\": {\"type\": \"Circle\", \"id\": \"d90692e4-1a50-4825-a0d5-9c7cb81836f7\"}, \"selection_glyph\": {\"type\": \"Circle\", \"id\": \"b8117f2d-d6d0-4684-a5d9-98f6d1de803f\"}, \"doc\": null, \"data_source\": {\"type\": \"ColumnDataSource\", \"id\": \"75c7cfc9-8bba-468d-b6ec-4893e22b5dc1\"}}}, {\"type\": \"BasicTickFormatter\", \"id\": \"98b5123c-71a0-41e1-aebf-703430ebf337\", \"attributes\": {\"tags\": [], \"doc\": null, \"id\": \"98b5123c-71a0-41e1-aebf-703430ebf337\"}}, {\"type\": \"DatetimeAxis\", \"id\": \"b4da3c40-caaa-4b98-ad61-d527525dbb97\", \"attributes\": {\"plot\": {\"type\": \"Plot\", \"id\": \"0fde0414-7c0a-4a79-96a8-40edc25397e2\", \"subtype\": \"Figure\"}, \"tags\": [], \"id\": \"b4da3c40-caaa-4b98-ad61-d527525dbb97\", \"doc\": null, \"formatter\": {\"type\": \"DatetimeTickFormatter\", \"id\": \"61a589c0-a828-443b-bd7b-98f0d8a9d440\"}, \"ticker\": {\"type\": \"DatetimeTicker\", \"id\": \"429f4ade-d381-43c2-92a0-cfe6d55ebed1\"}}}, {\"type\": \"Circle\", \"id\": \"b8117f2d-d6d0-4684-a5d9-98f6d1de803f\", \"attributes\": {\"tags\": [], \"x\": {\"field\": \"datetime\"}, \"line_color\": null, \"fill_color\": {\"value\": \"firebrick\"}, \"id\": \"b8117f2d-d6d0-4684-a5d9-98f6d1de803f\", \"size\": {\"units\": \"screen\", \"value\": 20}, \"y\": {\"field\": \"glucose\"}, \"doc\": null, \"fill_alpha\": {\"value\": 0.5}}}];\n",
" Bokeh.load_models(all_models);\n",
" var plots = [{'modeltype': 'Plot', 'elementid': '#bf45ed53-d36d-4aab-879d-fe97221a5c0f', 'modelid': '0fde0414-7c0a-4a79-96a8-40edc25397e2'}];\n",
" for (idx in plots) {\n",
" \tvar plot = plots[idx];\n",
" \tvar model = Bokeh.Collections(plot.modeltype).get(plot.modelid);\n",
" \tBokeh.logger.info('Realizing plot:')\n",
" \tBokeh.logger.info(' - modeltype: ' + plot.modeltype);\n",
" \tBokeh.logger.info(' - modelid: ' + plot.modelid);\n",
" \tBokeh.logger.info(' - elementid: ' + plot.elementid);\n",
" \tvar view = new model.default_view({\n",
" \t\tmodel: model,\n",
" \t\tel: plot.elementid\n",
" \t});\n",
" \tBokeh.index[plot.modelid] = view;\n",
" }\n",
" });\n",
" </script>\n",
"<div class=\"plotdiv\" id=\"bf45ed53-d36d-4aab-879d-fe97221a5c0f\"></div>\n",
"\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"callback = Callback(\n",
" args={\n",
" 'source': source\n",
" }, \n",
" code=code\n",
")\n",
"p.add_tools(\n",
" HoverTool(\n",
" tooltips=None, \n",
" callback=callback, \n",
" renderers=[cr], \n",
" mode='hline'\n",
" )\n",
")\n",
"\n",
"show(p)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>datetime</th>\n",
" <th>isig</th>\n",
" <th>glucose</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2010-10-06 00:03:00</td>\n",
" <td>20.12</td>\n",
" <td>143</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2010-10-06 00:08:00</td>\n",
" <td>20.84</td>\n",
" <td>147</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2010-10-06 00:13:00</td>\n",
" <td>20.88</td>\n",
" <td>150</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2010-10-06 00:18:00</td>\n",
" <td>20.9</td>\n",
" <td>152</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2010-10-06 00:23:00</td>\n",
" <td>20.84</td>\n",
" <td>152</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>2010-10-06 00:28:00</td>\n",
" <td>20.92</td>\n",
" <td>152</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>2010-10-06 00:33:00</td>\n",
" <td>21.44</td>\n",
" <td>154</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>2010-10-06 00:38:00</td>\n",
" <td>21.3</td>\n",
" <td>155</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>2010-10-06 00:43:00</td>\n",
" <td>20.3</td>\n",
" <td>142</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>2010-10-06 00:48:00</td>\n",
" <td>20.44</td>\n",
" <td>140</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>2010-10-06 00:53:00</td>\n",
" <td>19.88</td>\n",
" <td>138</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>2010-10-06 00:58:00</td>\n",
" <td>19.08</td>\n",
" <td>134</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>2010-10-06 01:03:00</td>\n",
" <td>19.02</td>\n",
" <td>131</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>2010-10-06 01:08:00</td>\n",
" <td>18.98</td>\n",
" <td>130</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>2010-10-06 01:13:00</td>\n",
" <td>18.6</td>\n",
" <td>128</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>2010-10-06 01:18:00</td>\n",
" <td>18.48</td>\n",
" <td>127</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>2010-10-06 01:23:00</td>\n",
" <td>18.52</td>\n",
" <td>126</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>2010-10-06 01:28:00</td>\n",
" <td>18.52</td>\n",
" <td>126</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>2010-10-06 01:33:00</td>\n",
" <td>18.52</td>\n",
" <td>126</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>2010-10-06 01:38:00</td>\n",
" <td>18.66</td>\n",
" <td>126</td>\n",
" </tr>\n",
" <tr>\n",
" <th>20</th>\n",
" <td>2010-10-06 01:43:00</td>\n",
" <td>18.88</td>\n",
" <td>127</td>\n",
" </tr>\n",
" <tr>\n",
" <th>21</th>\n",
" <td>2010-10-06 01:48:00</td>\n",
" <td>19.2</td>\n",
" <td>129</td>\n",
" </tr>\n",
" <tr>\n",
" <th>22</th>\n",
" <td>2010-10-06 01:53:00</td>\n",
" <td>19.5</td>\n",
" <td>131</td>\n",
" </tr>\n",
" <tr>\n",
" <th>23</th>\n",
" <td>2010-10-06 01:58:00</td>\n",
" <td>19.64</td>\n",
" <td>132</td>\n",
" </tr>\n",
" <tr>\n",
" <th>24</th>\n",
" <td>2010-10-06 02:03:00</td>\n",
" <td>20.02</td>\n",
" <td>134</td>\n",
" </tr>\n",
" <tr>\n",
" <th>25</th>\n",
" <td>2010-10-06 02:08:00</td>\n",
" <td>20.16</td>\n",
" <td>136</td>\n",
" </tr>\n",
" <tr>\n",
" <th>26</th>\n",
" <td>2010-10-06 02:13:00</td>\n",
" <td>20.12</td>\n",
" <td>136</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>2010-10-06 02:18:00</td>\n",
" <td>20.08</td>\n",
" <td>136</td>\n",
" </tr>\n",
" <tr>\n",
" <th>28</th>\n",
" <td>2010-10-06 02:23:00</td>\n",
" <td>20.02</td>\n",
" <td>136</td>\n",
" </tr>\n",
" <tr>\n",
" <th>29</th>\n",
" <td>2010-10-06 02:28:00</td>\n",
" <td>19.72</td>\n",
" <td>135</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>258</th>\n",
" <td>2010-10-06 21:33:00</td>\n",
" <td>33.18</td>\n",
" <td>214</td>\n",
" </tr>\n",
" <tr>\n",
" <th>259</th>\n",
" <td>2010-10-06 21:38:00</td>\n",
" <td>33.32</td>\n",
" <td>221</td>\n",
" </tr>\n",
" <tr>\n",
" <th>260</th>\n",
" <td>2010-10-06 21:43:00</td>\n",
" <td>33.3</td>\n",
" <td>225</td>\n",
" </tr>\n",
" <tr>\n",
" <th>261</th>\n",
" <td>2010-10-06 21:48:00</td>\n",
" <td>34.56</td>\n",
" <td>230</td>\n",
" </tr>\n",
" <tr>\n",
" <th>262</th>\n",
" <td>2010-10-06 21:53:00</td>\n",
" <td>34.14</td>\n",
" <td>232</td>\n",
" </tr>\n",
" <tr>\n",
" <th>263</th>\n",
" <td>2010-10-06 21:58:00</td>\n",
" <td>33.22</td>\n",
" <td>230</td>\n",
" </tr>\n",
" <tr>\n",
" <th>264</th>\n",
" <td>2010-10-06 22:03:00</td>\n",
" <td>31.48</td>\n",
" <td>223</td>\n",
" </tr>\n",
" <tr>\n",
" <th>265</th>\n",
" <td>2010-10-06 22:08:00</td>\n",
" <td>30.68</td>\n",
" <td>216</td>\n",
" </tr>\n",
" <tr>\n",
" <th>266</th>\n",
" <td>2010-10-06 22:13:00</td>\n",
" <td>29.64</td>\n",
" <td>208</td>\n",
" </tr>\n",
" <tr>\n",
" <th>267</th>\n",
" <td>2010-10-06 22:18:00</td>\n",
" <td>27.84</td>\n",
" <td>199</td>\n",
" </tr>\n",
" <tr>\n",
" <th>268</th>\n",
" <td>2010-10-06 22:23:00</td>\n",
" <td>27.12</td>\n",
" <td>191</td>\n",
" </tr>\n",
" <tr>\n",
" <th>269</th>\n",
" <td>2010-10-06 22:28:00</td>\n",
" <td>26.5</td>\n",
" <td>185</td>\n",
" </tr>\n",
" <tr>\n",
" <th>270</th>\n",
" <td>2010-10-06 22:33:00</td>\n",
" <td>25.98</td>\n",
" <td>181</td>\n",
" </tr>\n",
" <tr>\n",
" <th>271</th>\n",
" <td>2010-10-06 22:38:00</td>\n",
" <td>25.58</td>\n",
" <td>177</td>\n",
" </tr>\n",
" <tr>\n",
" <th>272</th>\n",
" <td>2010-10-06 22:43:00</td>\n",
" <td>25.92</td>\n",
" <td>176</td>\n",
" </tr>\n",
" <tr>\n",
" <th>273</th>\n",
" <td>2010-10-06 22:48:00</td>\n",
" <td>26.12</td>\n",
" <td>177</td>\n",
" </tr>\n",
" <tr>\n",
" <th>274</th>\n",
" <td>2010-10-06 22:53:00</td>\n",
" <td>25.54</td>\n",
" <td>176</td>\n",
" </tr>\n",
" <tr>\n",
" <th>275</th>\n",
" <td>2010-10-06 22:58:00</td>\n",
" <td>25.12</td>\n",
" <td>173</td>\n",
" </tr>\n",
" <tr>\n",
" <th>276</th>\n",
" <td>2010-10-06 23:03:00</td>\n",
" <td>24.72</td>\n",
" <td>171</td>\n",
" </tr>\n",
" <tr>\n",
" <th>277</th>\n",
" <td>2010-10-06 23:08:00</td>\n",
" <td>24.44</td>\n",
" <td>169</td>\n",
" </tr>\n",
" <tr>\n",
" <th>278</th>\n",
" <td>2010-10-06 23:13:00</td>\n",
" <td>23.12</td>\n",
" <td>163</td>\n",
" </tr>\n",
" <tr>\n",
" <th>279</th>\n",
" <td>2010-10-06 23:18:00</td>\n",
" <td>21.12</td>\n",
" <td>154</td>\n",
" </tr>\n",
" <tr>\n",
" <th>280</th>\n",
" <td>2010-10-06 23:23:00</td>\n",
" <td>22.4</td>\n",
" <td>152</td>\n",
" </tr>\n",
" <tr>\n",
" <th>281</th>\n",
" <td>2010-10-06 23:28:00</td>\n",
" <td>22.84</td>\n",
" <td>153</td>\n",
" </tr>\n",
" <tr>\n",
" <th>282</th>\n",
" <td>2010-10-06 23:33:00</td>\n",
" <td>22.78</td>\n",
" <td>154</td>\n",
" </tr>\n",
" <tr>\n",
" <th>283</th>\n",
" <td>2010-10-06 23:38:00</td>\n",
" <td>22.64</td>\n",
" <td>154</td>\n",
" </tr>\n",
" <tr>\n",
" <th>284</th>\n",
" <td>2010-10-06 23:43:00</td>\n",
" <td>22.08</td>\n",
" <td>153</td>\n",
" </tr>\n",
" <tr>\n",
" <th>285</th>\n",
" <td>2010-10-06 23:48:00</td>\n",
" <td>21.88</td>\n",
" <td>151</td>\n",
" </tr>\n",
" <tr>\n",
" <th>286</th>\n",
" <td>2010-10-06 23:53:00</td>\n",
" <td>21.98</td>\n",
" <td>150</td>\n",
" </tr>\n",
" <tr>\n",
" <th>287</th>\n",
" <td>2010-10-06 23:58:00</td>\n",
" <td>22.16</td>\n",
" <td>150</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>288 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" datetime isig glucose\n",
"0 2010-10-06 00:03:00 20.12 143\n",
"1 2010-10-06 00:08:00 20.84 147\n",
"2 2010-10-06 00:13:00 20.88 150\n",
"3 2010-10-06 00:18:00 20.9 152\n",
"4 2010-10-06 00:23:00 20.84 152\n",
"5 2010-10-06 00:28:00 20.92 152\n",
"6 2010-10-06 00:33:00 21.44 154\n",
"7 2010-10-06 00:38:00 21.3 155\n",
"8 2010-10-06 00:43:00 20.3 142\n",
"9 2010-10-06 00:48:00 20.44 140\n",
"10 2010-10-06 00:53:00 19.88 138\n",
"11 2010-10-06 00:58:00 19.08 134\n",
"12 2010-10-06 01:03:00 19.02 131\n",
"13 2010-10-06 01:08:00 18.98 130\n",
"14 2010-10-06 01:13:00 18.6 128\n",
"15 2010-10-06 01:18:00 18.48 127\n",
"16 2010-10-06 01:23:00 18.52 126\n",
"17 2010-10-06 01:28:00 18.52 126\n",
"18 2010-10-06 01:33:00 18.52 126\n",
"19 2010-10-06 01:38:00 18.66 126\n",
"20 2010-10-06 01:43:00 18.88 127\n",
"21 2010-10-06 01:48:00 19.2 129\n",
"22 2010-10-06 01:53:00 19.5 131\n",
"23 2010-10-06 01:58:00 19.64 132\n",
"24 2010-10-06 02:03:00 20.02 134\n",
"25 2010-10-06 02:08:00 20.16 136\n",
"26 2010-10-06 02:13:00 20.12 136\n",
"27 2010-10-06 02:18:00 20.08 136\n",
"28 2010-10-06 02:23:00 20.02 136\n",
"29 2010-10-06 02:28:00 19.72 135\n",
".. ... ... ...\n",
"258 2010-10-06 21:33:00 33.18 214\n",
"259 2010-10-06 21:38:00 33.32 221\n",
"260 2010-10-06 21:43:00 33.3 225\n",
"261 2010-10-06 21:48:00 34.56 230\n",
"262 2010-10-06 21:53:00 34.14 232\n",
"263 2010-10-06 21:58:00 33.22 230\n",
"264 2010-10-06 22:03:00 31.48 223\n",
"265 2010-10-06 22:08:00 30.68 216\n",
"266 2010-10-06 22:13:00 29.64 208\n",
"267 2010-10-06 22:18:00 27.84 199\n",
"268 2010-10-06 22:23:00 27.12 191\n",
"269 2010-10-06 22:28:00 26.5 185\n",
"270 2010-10-06 22:33:00 25.98 181\n",
"271 2010-10-06 22:38:00 25.58 177\n",
"272 2010-10-06 22:43:00 25.92 176\n",
"273 2010-10-06 22:48:00 26.12 177\n",
"274 2010-10-06 22:53:00 25.54 176\n",
"275 2010-10-06 22:58:00 25.12 173\n",
"276 2010-10-06 23:03:00 24.72 171\n",
"277 2010-10-06 23:08:00 24.44 169\n",
"278 2010-10-06 23:13:00 23.12 163\n",
"279 2010-10-06 23:18:00 21.12 154\n",
"280 2010-10-06 23:23:00 22.4 152\n",
"281 2010-10-06 23:28:00 22.84 153\n",
"282 2010-10-06 23:33:00 22.78 154\n",
"283 2010-10-06 23:38:00 22.64 154\n",
"284 2010-10-06 23:43:00 22.08 153\n",
"285 2010-10-06 23:48:00 21.88 151\n",
"286 2010-10-06 23:53:00 21.98 150\n",
"287 2010-10-06 23:58:00 22.16 150\n",
"\n",
"[288 rows x 3 columns]"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Initialize Pandas DataFrame Table\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment