{
 "metadata": {
  "name": "",
  "signature": "sha256:953d1749ce53b82695474fa18cae0b8df5fff77df124f45aa02f78f1f836dc58"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import bokeh\n",
      "bokeh.load_notebook()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from collections import OrderedDict\n",
      "\n",
      "from bokeh.charts import Scatter\n",
      "from bokeh.sampledata.iris import flowers\n",
      "\n",
      "setosa = flowers[(flowers.species == \"setosa\")][[\"petal_length\", \"petal_width\"]]\n",
      "versicolor = flowers[(flowers.species == \"versicolor\")][[\"petal_length\", \"petal_width\"]]\n",
      "virginica = flowers[(flowers.species == \"virginica\")][[\"petal_length\", \"petal_width\"]]\n",
      "\n",
      "xyvalues = OrderedDict([(\"setosa\", setosa.values), (\"versicolor\", versicolor.values), (\"virginica\", virginica.values)])\n",
      "\n",
      "scatter = Scatter(xyvalues)\n",
      "scatter.title(\"iris dataset, dict_input\").xlabel(\"petal_length\").ylabel(\"petal_width\").legend(\"top_left\").width(600).height(400).notebook().show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "groupped_df = flowers[[\"petal_length\", \"petal_width\", \"species\"]].groupby(\"species\")\n",
      "\n",
      "\n",
      "scatter = Scatter(groupped_df)\n",
      "scatter.title(\"iris dataset, df_input\").legend(\"top_left\").width(600).height(400).notebook().show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import pandas as pd\n",
      "\n",
      "pdict = OrderedDict()\n",
      "\n",
      "for i in groupped_df.groups.keys():\n",
      "    labels = groupped_df.get_group(i).columns\n",
      "    xname = labels[0]\n",
      "    yname = labels[1]\n",
      "    x = getattr(groupped_df.get_group(i), xname)\n",
      "    y = getattr(groupped_df.get_group(i), yname)\n",
      "    pdict[i] = list(zip(x, y))\n",
      "\n",
      "df = pd.DataFrame(pdict)\n",
      "scatter = Scatter(df)\n",
      "scatter.title(\"iris dataset, dict_input\").xlabel(\"petal_length\").ylabel(\"petal_width\").legend(\"top_left\").width(600).height(400).notebook().show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "scatter = Scatter(list(xyvalues.values()))\n",
      "scatter.title(\"iris dataset, dict_input\").xlabel(\"petal_length\").ylabel(\"petal_width\").legend(\"top_left\").width(600).height(400).notebook().show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}