{
 "metadata": {
  "name": "",
  "signature": "sha256:92ec46934ca6f9382b8531f06c304f42fa8c9cdbeff79cd558431bb5315ff122"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import absolute_import, print_function"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from bokeh.document import Document\n",
      "from bokeh.session import Session\n",
      "\n",
      "document = Document()\n",
      "session = Session()\n",
      "session.use_doc('table_server')\n",
      "session.load_document(document)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import pandas as pd\n",
      "from six.moves import cStringIO as StringIO\n",
      "\n",
      "antibiotics = \"\"\"\\\n",
      "bacteria,                        penicillin, streptomycin, neomycin, gram\n",
      "Mycobacterium tuberculosis,      800,        5,            2,        negative\n",
      "Salmonella schottmuelleri,       10,         0.8,          0.09,     negative\n",
      "Proteus vulgaris,                3,          0.1,          0.1,      negative\n",
      "Klebsiella pneumoniae,           850,        1.2,          1,        negative\n",
      "Brucella abortus,                1,          2,            0.02,     negative\n",
      "Pseudomonas aeruginosa,          850,        2,            0.4,      negative\n",
      "Escherichia coli,                100,        0.4,          0.1,      negative\n",
      "Salmonella (Eberthella) typhosa, 1,          0.4,          0.008,    negative\n",
      "Aerobacter aerogenes,            870,        1,            1.6,      negative\n",
      "Brucella antracis,               0.001,      0.01,         0.007,    positive\n",
      "Streptococcus fecalis,           1,          1,            0.1,      positive\n",
      "Staphylococcus aureus,           0.03,       0.03,         0.001,    positive\n",
      "Staphylococcus albus,            0.007,      0.1,          0.001,    positive\n",
      "Streptococcus hemolyticus,       0.001,      14,           10,       positive\n",
      "Streptococcus viridans,          0.005,      10,           40,       positive\n",
      "Diplococcus pneumoniae,          0.005,      11,           10,       positive\n",
      "\"\"\"\n",
      "\n",
      "data = pd.read_csv(StringIO(antibiotics), skipinitialspace=True)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from bokeh.widgetobjects import HandsonTable, TableColumn\n",
      "from bokeh.objects import ColumnDataSource\n",
      "\n",
      "source = ColumnDataSource(data=data)\n",
      "columns = [\n",
      "    TableColumn(data=\"bacteria\", type=\"text\", header=\"Bacteria\"),\n",
      "    TableColumn(data=\"penicillin\", type=\"numeric\", header=\"Penicillin\"),\n",
      "    TableColumn(data=\"streptomycin\", type=\"numeric\", header=\"Streptomycin\"),\n",
      "    TableColumn(data=\"neomycin\", type=\"numeric\", header=\"Neomycin\"),\n",
      "    TableColumn(data=\"gram\", type=\"autocomplete\", source=[\"negative\", \"positive\"], header=\"Gram\"),\n",
      "]\n",
      "data_table = HandsonTable(source=source, columns=columns)\n",
      "document.add(data_table)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "session.store_document(document)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "session.show(data_table)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}
