將 DataFrame 顯示為交互式表格。
函數簽名
st.dataframe(data=None, width=None, height=None)
參數 | 說明 |
---|---|
data (pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, Iterable, dict, or None) | 要顯示的數據。 如果 'data' 是 pandas.Styler,它將用於設置其底層 DataFrame 的樣式。 Streamlit 支持自定義單元格值和顏色。 (它不支持一些更具異國情調的 pandas 樣式函數,例如條形圖、懸停和標題。)樣式器支持是實驗性的! Streamlit 的舊版 DataFrame 序列化(即使用 |
width (int or None) | 以像素表示的 UI 元素的所需寬度。如果沒有,則使用基於頁麵寬度的默認寬度。 |
height (int or None) | 以像素表示的 UI 元素的所需高度。如果沒有,則使用默認高度。 |
例子
df = pd.DataFrame(
np.random.randn(50, 20),
columns=('col %d' % i for i in range(20)))
st.dataframe(df) # Same as st.write(df)
st.dataframe(df, 200, 100)
您還可以傳遞 Pandas Styler 對象來更改渲染 DataFrame 的樣式:
df = pd.DataFrame(
np.random.randn(10, 20),
columns=('col %d' % i for i in range(20)))
st.dataframe(df.style.highlight_max(axis=0))
相關用法
- Python Streamlit st.date_input用法及代碼示例
- Python Streamlit st.download_button用法及代碼示例
- Python Streamlit st.experimental_singleton.clear用法及代碼示例
- Python Streamlit st.bokeh_chart用法及代碼示例
- Python Streamlit st.caption用法及代碼示例
- Python Streamlit st.text_input用法及代碼示例
- Python Streamlit st.area_chart用法及代碼示例
- Python Streamlit st.title用法及代碼示例
- Python Streamlit st.cache用法及代碼示例
- Python Streamlit st.experimental_singleton用法及代碼示例
- Python Streamlit st.empty用法及代碼示例
- Python Streamlit st.error用法及代碼示例
- Python Streamlit st.video用法及代碼示例
- Python Streamlit st.vega_lite_chart用法及代碼示例
- Python Streamlit st.slider用法及代碼示例
- Python Streamlit st.header用法及代碼示例
- Python Streamlit st.container用法及代碼示例
- Python Streamlit st.form_submit_button用法及代碼示例
- Python Streamlit st.form用法及代碼示例
- Python Streamlit st.plotly_chart用法及代碼示例
- Python Streamlit st.bar_chart用法及代碼示例
- Python Streamlit st.code用法及代碼示例
- Python Streamlit st.experimental_memo.clear用法及代碼示例
- Python Streamlit st.warning用法及代碼示例
- Python Streamlit st.image用法及代碼示例
注:本文由純淨天空篩選整理自streamlit.io大神的英文原創作品 st.dataframe。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。