Skip to content

Instantly share code, notes, and snippets.

@olgabot
Forked from anonymous/001_make_dashboard.ipynb
Last active June 23, 2017 17:54
Show Gist options
  • Save olgabot/803c46eace1a5eff44c7d6184813d849 to your computer and use it in GitHub Desktop.
Save olgabot/803c46eace1a5eff44c7d6184813d849 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/olgabot/anaconda3/envs/maca/lib/python3.6/site-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated since IPython 4.0. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.\n",
" \"`IPython.html.widgets` has moved to `ipywidgets`.\", ShimWarning)\n"
]
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import seaborn as sns\n",
"import sklearn\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import dash\n",
"import dash_html_components as dhc\n",
"import dash_core_components as dcc"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "AttributeError",
"evalue": "module 'dash' has no attribute 'react'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-3-f09488cadf25>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mapp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdash\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreact\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDash\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Dash Hello World'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mtext_style\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcolor\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'#444'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfontFamily\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'sans-serif'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfontWeight\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m300\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mplotly_figure\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m8\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mAttributeError\u001b[0m: module 'dash' has no attribute 'react'"
]
}
],
"source": [
"app = dash.react.Dash('Dash Hello World')\n",
"\n",
"text_style = dict(color='#444', fontFamily='sans-serif', fontWeight=300)\n",
"plotly_figure = dict(data=[dict(x=[1,2,3], y=[2,4,8])])\n",
"\n",
"app.layout = dhc.Div([ \n",
" dhc.H2('My First Dash App', style=text_style),\n",
" dhc.P('Enter a Plotly trace type into the text box, such as histogram, bar, or scatter.', style=text_style),\n",
" dcc.Input(id='text1', placeholder='box', value=''),\n",
" dcc.Graph(id='plot1', figure=plotly_figure),\n",
" ])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (MACA)",
"language": "python",
"name": "maca"
},
"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.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
(maca) ➜ ~ python --version
Python 3.6.1 :: Continuum Analytics, Inc.
(maca) ➜ ~ pip install dash
Collecting dash
Downloading dash-0.17.7.tar.gz
Collecting Flask>=0.12 (from dash)
Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
100% |████████████████████████████████| 92kB 3.1MB/s
Collecting flask-compress (from dash)
Downloading Flask-Compress-1.4.0.tar.gz
Collecting flask-seasurf (from dash)
Downloading Flask-SeaSurf-0.2.2.tar.gz
Collecting plotly (from dash)
Downloading plotly-2.0.11.tar.gz (1.0MB)
100% |████████████████████████████████| 1.0MB 673kB/s
Collecting Jinja2>=2.4 (from Flask>=0.12->dash)
Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB)
100% |████████████████████████████████| 348kB 2.6MB/s
Collecting Werkzeug>=0.7 (from Flask>=0.12->dash)
Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
100% |████████████████████████████████| 317kB 1.9MB/s
Collecting click>=2.0 (from Flask>=0.12->dash)
Downloading click-6.7-py2.py3-none-any.whl (71kB)
100% |████████████████████████████████| 71kB 5.1MB/s
Collecting itsdangerous>=0.21 (from Flask>=0.12->dash)
Downloading itsdangerous-0.24.tar.gz (46kB)
100% |████████████████████████████████| 51kB 6.7MB/s
Requirement already satisfied: decorator>=4.0.6 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from plotly->dash)
Collecting nbformat>=4.2 (from plotly->dash)
Using cached nbformat-4.3.0-py2.py3-none-any.whl
Requirement already satisfied: pytz in ./anaconda3/envs/maca/lib/python3.6/site-packages (from plotly->dash)
Collecting requests (from plotly->dash)
Downloading requests-2.18.1-py2.py3-none-any.whl (88kB)
100% |████████████████████████████████| 92kB 5.2MB/s
Requirement already satisfied: six in ./anaconda3/envs/maca/lib/python3.6/site-packages (from plotly->dash)
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask>=0.12->dash)
Downloading MarkupSafe-1.0.tar.gz
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat>=4.2->plotly->dash)
Using cached jsonschema-2.6.0-py2.py3-none-any.whl
Requirement already satisfied: jupyter-core in ./anaconda3/envs/maca/lib/python3.6/site-packages (from nbformat>=4.2->plotly->dash)
Requirement already satisfied: ipython-genutils in ./anaconda3/envs/maca/lib/python3.6/site-packages (from nbformat>=4.2->plotly->dash)
Requirement already satisfied: traitlets>=4.1 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from nbformat>=4.2->plotly->dash)
Collecting urllib3<1.22,>=1.21.1 (from requests->plotly->dash)
Downloading urllib3-1.21.1-py2.py3-none-any.whl (131kB)
100% |████████████████████████████████| 133kB 3.8MB/s
Collecting idna<2.6,>=2.5 (from requests->plotly->dash)
Downloading idna-2.5-py2.py3-none-any.whl (55kB)
100% |████████████████████████████████| 61kB 6.7MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests->plotly->dash)
Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
100% |████████████████████████████████| 143kB 3.9MB/s
Collecting certifi>=2017.4.17 (from requests->plotly->dash)
Downloading certifi-2017.4.17-py2.py3-none-any.whl (375kB)
100% |████████████████████████████████| 378kB 1.6MB/s
Building wheels for collected packages: dash, flask-compress, flask-seasurf, plotly, itsdangerous, MarkupSafe
Running setup.py bdist_wheel for dash ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/04/f4/a1/e09bfcbb7b66b414e8a7e0e131c2c39ca9cd978921482390b8
Running setup.py bdist_wheel for flask-compress ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/42/1e/83/8f3999abe10ae8f4f6463fd20e321b398d104c8c51b2401ca3
Running setup.py bdist_wheel for flask-seasurf ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/84/9c/6b/c80d276ff8635fdbf9fc3f9b74f43124afdbc6c038eee8cd72
Running setup.py bdist_wheel for plotly ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/42/0e/32/4c21416a45ad6efe5daa0a2c9fe358c54a3b4fa6223ad69922
Running setup.py bdist_wheel for itsdangerous ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/fc/a8/66/24d655233c757e178d45dea2de22a04c6d92766abfb741129a
Running setup.py bdist_wheel for MarkupSafe ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57
Successfully built dash flask-compress flask-seasurf plotly itsdangerous MarkupSafe
Installing collected packages: MarkupSafe, Jinja2, Werkzeug, click, itsdangerous, Flask, flask-compress, flask-seasurf, jsonschema, nbformat, urllib3, idna, chardet, certifi, requests, plotly, dash
Successfully installed Flask-0.12.2 Jinja2-2.9.6 MarkupSafe-1.0 Werkzeug-0.12.2 certifi-2017.4.17 chardet-3.0.4 click-6.7 dash-0.17.7 flask-compress-1.4.0 flask-seasurf-0.2.2 idna-2.5 itsdangerous-0.24 jsonschema-2.6.0 nbformat-4.3.0 plotly-2.0.11 requests-2.18.1 urllib3-1.21.1
(maca) ➜ ~ pip install dash.ly plotly dash_html_components dash_core_components dash_renderer
Collecting dash.ly
Downloading dash.ly-0.17.3.tar.gz
Requirement already satisfied: plotly in ./anaconda3/envs/maca/lib/python3.6/site-packages
Collecting dash_html_components
Downloading dash_html_components-0.6.2.tar.gz (43kB)
100% |████████████████████████████████| 51kB 4.6MB/s
Collecting dash_core_components
Downloading dash_core_components-0.5.1.tar.gz (969kB)
100% |████████████████████████████████| 972kB 754kB/s
Collecting dash_renderer
Downloading dash_renderer-0.7.3.tar.gz (125kB)
100% |████████████████████████████████| 133kB 3.7MB/s
Requirement already satisfied: Flask>=0.12 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from dash.ly)
Requirement already satisfied: flask-compress in ./anaconda3/envs/maca/lib/python3.6/site-packages (from dash.ly)
Requirement already satisfied: flask-seasurf in ./anaconda3/envs/maca/lib/python3.6/site-packages (from dash.ly)
Requirement already satisfied: decorator>=4.0.6 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from plotly)
Requirement already satisfied: pytz in ./anaconda3/envs/maca/lib/python3.6/site-packages (from plotly)
Requirement already satisfied: requests in ./anaconda3/envs/maca/lib/python3.6/site-packages (from plotly)
Requirement already satisfied: nbformat>=4.2 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from plotly)
Requirement already satisfied: six in ./anaconda3/envs/maca/lib/python3.6/site-packages (from plotly)
Requirement already satisfied: dash in ./anaconda3/envs/maca/lib/python3.6/site-packages (from dash_html_components)
Requirement already satisfied: Werkzeug>=0.7 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from Flask>=0.12->dash.ly)
Requirement already satisfied: click>=2.0 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from Flask>=0.12->dash.ly)
Requirement already satisfied: itsdangerous>=0.21 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from Flask>=0.12->dash.ly)
Requirement already satisfied: Jinja2>=2.4 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from Flask>=0.12->dash.ly)
Requirement already satisfied: urllib3<1.22,>=1.21.1 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from requests->plotly)
Requirement already satisfied: certifi>=2017.4.17 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from requests->plotly)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from requests->plotly)
Requirement already satisfied: idna<2.6,>=2.5 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from requests->plotly)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from nbformat>=4.2->plotly)
Requirement already satisfied: jupyter-core in ./anaconda3/envs/maca/lib/python3.6/site-packages (from nbformat>=4.2->plotly)
Requirement already satisfied: traitlets>=4.1 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from nbformat>=4.2->plotly)
Requirement already satisfied: ipython-genutils in ./anaconda3/envs/maca/lib/python3.6/site-packages (from nbformat>=4.2->plotly)
Requirement already satisfied: MarkupSafe>=0.23 in ./anaconda3/envs/maca/lib/python3.6/site-packages (from Jinja2>=2.4->Flask>=0.12->dash.ly)
Building wheels for collected packages: dash.ly, dash-html-components, dash-core-components, dash-renderer
Running setup.py bdist_wheel for dash.ly ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/ad/8d/fc/25f9788baa34e7360ebef8fce0fb7d04c8c1d4bea0122cf637
Running setup.py bdist_wheel for dash-html-components ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/1e/37/3c/4a769a639db16cd6f42ba3c39f214e59495d7f616433d7050d
Running setup.py bdist_wheel for dash-core-components ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/83/e1/1e/7ebc4d6aa297ac24fb22d231e6f09c2d6014ec7d9864606914
Running setup.py bdist_wheel for dash-renderer ... done
Stored in directory: /Users/olgabot/Library/Caches/pip/wheels/b2/49/ce/a35bdd5db181b2b3c941552215f7bb82267399ae6ab66372ed
Successfully built dash.ly dash-html-components dash-core-components dash-renderer
Installing collected packages: dash.ly, dash-html-components, dash-core-components, dash-renderer
Successfully installed dash-core-components-0.5.1 dash-html-components-0.6.2 dash-renderer-0.7.3 dash.ly-0.17.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment