将 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。