Streamli
1 年前
1.运行
运行streamlit python脚本:
streamlit run your_script.py [-- script args]
pycharm运行streamlit python脚本
$ python -m streamlit run your_script.py
$ streamlit run your_script.py
2.开发流
要更新app,只需要更新代码然后保存代码再运行,选择"Always rerun",app自动更新。很方便。
3.数据流
你要做任何更新的时候,Streamlit 会从模块顶部运行到结束。
相当于重新运行模块。这个会发生在两个情况下:
1.Whenever you modify your app's source code.
改动源代码
2.Whenever a user interacts with widgets in the app. For example, when dragging a slider, entering text in an input box, or clicking a button.
交互
4.展示数据
(出现问题:“gt”命令需要使用命令行开发者工具。您要现在安装该工具吗?选取“安装”来立即下载并安装命令行开发者工具。
$ xcode-select --install
$ pip install watchdog
)
1.一些方法
"""
# My first app
Here's our first attempt at using data to create a table:
import streamlit as st
import pandas as pd
df = pd.DataFrame({
'first column': [1, 2, 3, 4],
'second column': [10, 20, 30, 40]
df #这行代码可以在web上展现df,相当于自动实现st.write()
st.write()
:可以输入几乎任何数据,比如text, data, Matplotlib figures, Altair charts, and more
import streamlit as st
import pandas as pd
st.write("Here's our first attempt at using data to create a table:")
st.write(pd.DataFrame({
'first column': [1, 2, 3, 4],
'second column': [10, 20, 30, 40]