{
 "metadata": {
  "name": "",
  "signature": "sha256:98d7bd98dfb8f0ea68c8d3337f2f8d49691b5e48dba1e3494fc4df9cca8b56ad"
 },
 "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 bokeh.sampledata.unemployment1948 import data\n",
      "\n",
      "# pandas magic\n",
      "df = data[data.columns[:-2]]\n",
      "df2 = df.set_index(df[df.columns[0]].astype(str))\n",
      "df2.drop(df.columns[0], axis=1, inplace=True)\n",
      "df3 = df2.transpose()\n",
      "\n",
      "from bokeh.palettes import Purples9 as palette\n",
      "\n",
      "# bokeh magic\n",
      "from bokeh.charts import HeatMap\n",
      "hm = HeatMap(df3, palette=palette, title=\"categorical heatmap, pd_input\", notebook=True)\n",
      "hm.width(1000).height(400).show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "hm_data = df3.values.T\n",
      "hm = HeatMap(hm_data, palette=palette, title=\"Unemployment (Array)\", xlabel='Years since 1948', ylabel='Months', notebook=True)\n",
      "hm.width(1000).height(400).show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import pandas as pd\n",
      "\n",
      "simple_df = pd.DataFrame(\n",
      "    {'apples':[4,5,8,12,4], 'pears':[6,5,4,8,7], 'bananas':[1,2,4,8,12]}, \n",
      "    index=['2009', '2010', '2011', '2012', '2013']\n",
      ")\n",
      "hm = HeatMap(simple_df, palette=palette, title=\"Fruit comsumption per year\", notebook=True)\n",
      "hm.width(1000).height(400).show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}
