西安做網(wǎng)站公司網(wǎng)絡(luò)優(yōu)化師是什么工作
??? 天 14
Streamlit 組件s
Streamlit 組件s 是第三方的 Python 模塊,對(duì) Streamlit 進(jìn)行拓展 [1].
有哪些可用的 Streamlit 組件s?
好幾十個(gè)精選 Streamlit 組件s 羅列在 Streamlit 的網(wǎng)站上 [2].
Fanilo(一位 Streamlit 創(chuàng)作者)在 wiki 帖子中組織了一個(gè)很棒的 Streamlit 組件s 列表 [3]。截至 2022 年 4 月,其列出了約 85 個(gè) Streamlit 組件s 。
如何使用?
Streamlit 組件s 只需要通過 pip 安裝即可使用。
在這篇教程中,我們將教會(huì)你如何使用 streamlit_pandas_profiling
組件 [4].
安裝組件
pip install streamlit_pandas_profiling
示例應(yīng)用
代碼
以下是如何使用這個(gè)組件來構(gòu)建 Streamlit 應(yīng)用:
import streamlit as st
import pandas as pd
import pandas_profiling
from streamlit_pandas_profiling import st_profile_report#標(biāo)題設(shè)定
st.header('`streamlit_pandas_profiling`')#導(dǎo)入數(shù)據(jù)文件
df = pd.read_csv('https://raw.githubusercontent.com/dataprofessor/data/master/penguins_cleaned.csv')pr = df.profile_report()
st_profile_report(pr)
逐行解釋
創(chuàng)建 Streamlit 應(yīng)用時(shí)要做的第一件事就是將 streamlit
庫導(dǎo)入為 st
,以及導(dǎo)入其他要用到的庫:
import streamlit as st
import pandas as pd
import pandas_profiling
from streamlit_pandas_profiling import st_profile_report
然后緊跟著的是應(yīng)用的標(biāo)題文字:
st.header('`streamlit_pandas_profiling`')
接下來我們使用 pandas
中的 read_csv
命令載入 Penguins 數(shù)據(jù)集。
df = pd.read_csv('https://raw.githubusercontent.com/dataprofessor/data/master/penguins_cleaned.csv')
最后,由 profile_report()
命令生成分析報(bào)告,并用 st_profile_report
顯示出來:
pr = df.profile_report()
st_profile_report(pr)
制作你自己的組件
如果你對(duì)于制作自己的組件感興趣,請(qǐng)查閱以下這些資源:
- 制作組件
- 發(fā)布組件
- 組件 API
- 有關(guān)組件的博客帖子
如果你更愿意通過視頻學(xué)習(xí),我們的工程師 Tim Conkling 也做了一些超棒的教程:
- 如何構(gòu)建一個(gè) Streamlit 組件s | Part 1: 配置與架構(gòu)
- 如何構(gòu)建一個(gè) Streamlit 組件s | Part 2: 制作一個(gè)滑條組件
有關(guān)組件的延伸閱讀
- Streamlit 組件s - API 文檔
- 精選 Streamlit 組件s
- Streamlit 組件s - 社區(qū)追蹤
- streamlit_pandas_profiling
??? 天 15
st.latex
st.latex
以 LaTeX 語法顯示數(shù)學(xué)公式。