streamlit table转置显示,并且原始的表头放在最左侧
原始表格
代码
import streamlit as st
import pandas as pd
# 创建一个示例 DataFrame
data = {
'Column1': [1, 2, 3],
'Column2': [4, 5, 6],
'Column3': [7, 8, 9]
}
df = pd.DataFrame(data)
# 转置 DataFrame
transposed_df = df.T.reset_index()
# 更改列名
transposed_df.columns = ['Original Header'] + list(transposed_df.columns[1:])
# 显示转置的 DataFrame
st.table(transposed_df)