Skip to content

Latest commit

 

History

History
225 lines (164 loc) · 4.86 KB

slides.md

File metadata and controls

225 lines (164 loc) · 4.86 KB
title subtitle lang author date
Dash
reactive dashboards in Python
eng
December 5th 2017, Haute École Arc Ingénierie,<br/>St-Imier

Summary

  • What is Dash?
    • Use cases
    • Friendly projects
  • Examples
  • Alternatives
  • Advantages and disadvantages
  • Questions

What is Dash?

"Dash is a Python framework for building analytical web applications. No JavaScript required."

-- Dash website --


Dash: under the hood

This library is based on:

  • Plotly: Plot data in numerous ways
  • Flask: make plots accessible through a web application
  • React: make dashboards reactive and update automatically when you change data filter parameters

Dash use cases

  • Monitor or examine data for datascience purpose
  • Build customized business intelligence web applications

Dash-friendly libraries

  • Pandas: data loading and filtering
    • .csv files and database support
    • {inner, left, right} join on your data
    • Plots accept pandas DataFrame as input data by default
  • pandas: DataFrames

Examples



<iframe src="https://plot.ly/dash/gallery/live-wind-data/" style="height: 640px; width: 100%; border: 0; overflow: hidden;"> </iframe>

Other examples


Example project

  • Business process mining
  • Tons of messy data
  • Explore data to understand the process
  • Machine learning once the process is undestood
  • csv files with millions of lines
  • Joins made with pandas
  • Created new and «easier to use» csv files
  • New csv files loaded by the Web application and used in the dashboards

Alternatives

  • Other libaries exist but without interactivity.
  • Ready to use softwares might do the job when you don't need custom plots.

Advantages

  • Open source project: https://github.com/plotly/dash
  • Plots are reactive and fast (WebGL!)
  • Few tweaks are necessary to make plots look nice
  • Possibility to add JavaScript and CSS files
  • Based on cutting edge web technologies
  • All the data processing stuff can be done in Python
  • Open source: pretty fast development
  • Tweaks: default CSS is not that bad
  • Process everything in Python --> avoid JavaScript suprises
  • Example: I used materialize in a project

Disadvantages

  • Generate the HTML using Dash HTML components and Dash Core Components.
  • Dash is new. Is it mature enough?

Questions


Simple code example

Launch these commands from a terminal to install the Python packages:

pip install dash==0.19.0  # The core dash backend
pip install dash-renderer==0.11.1  # The dash front-end
pip install dash-html-components==0.8.0  # HTML components
pip install dash-core-components==0.14.0  # Supercharged components
pip install plotly --upgrade  # Latest Plotly graphing library

Simple code example

Create a file named app.py:

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()

app.layout = html.Div(children=[
    html.H1(children='Hello Dash'),

    html.Div(children='''
        Dash: A web application framework for Python.
    '''),

    dcc.Graph(
        id='example-graph',
        figure={
            'data': [
                {'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'SF'},
                {'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': u'Montréal'},
            ],
            'layout': {
                'title': 'Dash Data Visualization'
            }
        }
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

Simple code example

Run the app with the following command:

python app.py