Dash是一个基于Web应用程序、用于分析的Python库,开发时间已达两年之久。最初,Plotly在GitHub上公布了Dash的概念验证,经过长时间不间断的开发,Plotly发布了作为企业级解决方案和开源工具的Dash。Dash项目可用于数据分析、数据挖掘、可视化、建模、仪器控制和报告。这是一个轻量级的项目,只有40行Python,并且提供了一个用于键入UI控件的界面,包含滑块,下拉列表和带代码的图形等等。最重要的是Dash是完全可定制化的。
有企业曾表示,我们与Dash Enterprise的目标是在内部共享Dash应用程序,无需开发人员,尽可能简单和安全。Dash Enterprise负责URL路由、监控、故障处理、部署、版本控制和程序包管理。用户可以在本地无限制的使用开源版本,也可以通过Heroku或Digital Ocean等平台管理Dash应用程序的部署。
Plotly公司在Dash项目网站上写道:Explore data, tweak your models, monitor your experiments, or roll your own business intelligence platform. Dash is the front-end to your analytical Python backend。(来自搜狐科技)
关于具体介绍可参见作者Plotly,Chris Pamer写的内容,原文链接:
https://link.jianshu.com/?t=https%3A%2F%2Fmedium.com%2F%40plotlygraphs%2Fintroducing-dash-5ecf7191b503
下面是一个将下拉菜单与支持D3.js的Plotly图形结合的Dash应用。用户通过筛选下拉菜单来选择不同的值,程序代码就能动态地从谷歌金融导入数据到Pandas的DataFrame。然而,这个应用仅用了43行代码!
Dash应用:Hello World,更多请查阅用户指南
下面是官网上的一个超级精彩的交互式界面的例子:
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
from plotly import graph_objs as go
from datetime import datetime as dt
import json
import pandas as pd
df_fund_data = pd.read_csv('https://plot.ly/~jackp/17534.csv')
df_fund_data.head()
df_perf_summary = pd.read_csv('https://plot.ly/~jackp/17530.csv')
df_perf_summary.head()
df_cal_year = pd.read_csv('https://plot.ly/~jackp/17528.csv')
df_cal_year.head()
df_perf_pc = pd.read_csv('https://plot.ly/~jackp/17532.csv')
def make_dash_table( df ):
''' Return a dash definitio of an HTML table for a Pandas dataframe '''
table = []
for index, row in df.iterrows():
html_row = []
for i in range(len(row)):
html_row.append( html.Td([ row[i] ]) )
table.append( html.Tr( html_row ) )
return table
modifed_perf_table = make_dash_table( df_perf_summary )
modifed_perf_table.insert(
0, html.Tr( [
html.Td([]),
html.Td(['Cumulative'], colSpan=4, style=dict(textAlign="center")),
html.Td(['Annualised'], colSpan=4, style=dict(textAlign="center"))
], style = dict( background='white', fontWeight=600 )
)
)
df_fund_info = pd.read_csv('https://plot.ly/~jackp/17544.csv')
df_fund_characteristics = pd.read_csv('https://plot.ly/~jackp/17542.csv')
df_fund_facts = pd.read_csv('https://plot.ly/~jackp/17540.csv')
df_bond_allocation = pd.read_csv('https://plot.ly/~jackp/17538.csv')
dash.__version__
app