01.Python Dash网页开发:环境配置和初试

Dash类似R语言中的Shiny包,可以使用纯Python代码而不需要学习HTML、CSS、JavaScript语言就可以快速搭建一个网站,dash-bootstrap-components是Dash的拓展,提供了很多特性。

 

official site

Dash

https://dash.plotly.com/

 

dash-bootstrap-components(dbc)

https://dash-bootstrap-components.opensource.faculty.ai/

 

conda环境配置

我一直使用的是micromamba,因为比conda速度快,语法和conda一样,其中Dash网站所需要的4个包名字是dash开头,其他包是平时数据分析所需要用的;这里并未指定Python版本,自动安装的python是最新版3.10。

 

micromamba create -n dash;micromamba activate dash

micromamba -y install -c anaconda ipywidgets pandas numpy seaborn scikit-learn

micromamba -y install -c conda-forge matplotlib ipykernel dash dash-core-components dash-html-components dash-bootstrap-components

Dash网页APP初试

这里使用的是dbc官网的案例,模仿Shiny包使用KMeans给iris数据集聚类。

 

先不用管代码怎么写的,先跑起来。

 

新进一个文件iris_dash.py把下边代码复制进去。

 

"""

Dash port of Shiny iris k-means example:

 

https://shiny.rstudio.com/gallery/kmeans-example.html

"""

import dash

import dash_bootstrap_components as dbc

import pandas as pd

import plotly.grap

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值