streamlit 表格
时间: 2023-10-06 07:11:56 浏览: 120
streamlit表格可以通过使用streamlit-aggrid模块来实现。首先需要引入streamlit和pandas模块,以及streamlit-aggrid模块。然后使用st.file_uploader组件上传表格文件,并通过pandas的read_csv方法读取上传的文件数据。最后使用AgGrid将数据展示为表格形式。
示例代码如下:
```
import streamlit as st
import pandas as pd
from st_aggrid import AgGrid
file = st.file_uploader("请上传表格", type=["csv"])
if file is not None:
df = pd.read_csv(file, encoding="gbk")
AgGrid(
pd.DataFrame(df, columns=df.columns),
fit_columns_on_grid_load=True,
height=100,
)
```
这样,就可以在streamlit应用中展示上传的表格数据并以表格形式呈现出来。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [python教程77--agrid-Streamit表格功能组件介绍详解](https://blog.csdn.net/itmsn/article/details/121732175)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [用streamlit,几行代码就可以拥有漂亮图表!](https://blog.csdn.net/weixin_48923393/article/details/130818334)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文