{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "## Hello, I'm ***IPython-Dashboar***, which is inspired by one of the greatest packages, ***IPython***.\n", "\n", "I'm a stand alone, light-weight web server for building, sharing graphs created in ipython. Aiming at building for data science, data analysis guys. Building an interactive visualization, collaborated dashboard, and real-time streaming graph.\n", "\n", "If you are doing data exploring in IPython notebook, and draw some graph or select some metrics from database, which will be used to present to others, but you don't like to share the code or the complicated logic [ for private or page cleaning ], I think I can help you to do the present part job.\n", "\n", "In this tutorial, I'll show you how to do data exploring in ipython notebook and how to share it to others without ipython.\n", "\n", "![usage](usage-1.jpg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Load packages [ One can't make bricks without straw ]\n", "\n", "\n", "- I recommend import package in a readable and reasonable order, which will be useful as the project gets larger.\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# built-in package\n", "import os\n", "import sys\n", "import json\n", "import time\n", "import datetime as dt\n", "\n", "# third-parth package\n", "import dashboard as dash\n", "import pandas as pd\n", "import matplotlib as plt\n", "import seaborn\n", "import mpld3\n", "\n", "# package configre\n", "pd.options.display.max_columns = 100\n", "pd.options.display.max_rows = 500" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Load data \n", "\n", "- I've prepared a test data on this repo.\n", "- Don't forget to take a look at the data before exploring it, that's a good habit." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "url = \"\"\"https://github.com/litaotao/IPython-Dashboard/raw/v-0.1.2-visualiza-table/docs/people_number_by_province_lateset_10_years.csv\"\"\"\n", "data = pd.read_csv(url)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
地区2014年2013年2012年2011年2010年2009年2008年2007年2006年2005年
0北京市2152211520692019196218601771167616011538
1天津市1517147214131355129912281176111510751043
2河北省7384733372887241719470346989694368986851
\n", "
" ], "text/plain": [ " 地区 2014年 2013年 2012年 2011年 2010年 2009年 2008年 2007年 2006年 2005年\n", "0 北京市 2152 2115 2069 2019 1962 1860 1771 1676 1601 1538\n", "1 天津市 1517 1472 1413 1355 1299 1228 1176 1115 1075 1043\n", "2 河北省 7384 7333 7288 7241 7194 7034 6989 6943 6898 6851" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head(3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Traditionaly way of plotting [ I really like ipython indeed, but ... ]\n", "\n", "- matplotlib + seaborn + mpld3 : I really like it very much, but ...\n", "- raw html : ok, it a way indeed, but ..." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.plot(x=\"地区\", y=[\"2014年\", \"2013年\"], kind=\"bar\", figsize=(12, 5))\n", "mpld3.display()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. Not enough even arm matplotlib with seaborn, mpld3\n", "\n", "- If you just wanna share this graph above to others ?\n", "- if you wanna hidden/show a specific field, eg, just show one years' population ?\n", "- If you wanna know the exact number of a bar when the hovering on the bar ?\n", "- if ...\n", "- if ...\n", "\n", "![are-you-crazy](are-you-crazy.jpg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 5. How IPython-Dashboard make it simple\n", "\n", "- No need to code complicated graph settings\n", "- Flexible to define\n", "- Able to share one graph, multi-graph in a dashboard\n", "- More ? coming soon ..." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 5.1 Firstly, send you data to the IPython-Dashboard" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dash.client.sender(data, key='chinese_population', force=True)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": true }, "source": [ "### 5.2 Secondly, oh, there is no second step, you can explore your graph, dashboard as long as opening [browser](http://127.0.0.1:9090)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![have-fun](have-fun.jpg)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.10" } }, "nbformat": 4, "nbformat_minor": 0 }