我下面的这个简单例子在@MathCatsAnd的帮助下创立。 每一页<代码><>>>有多个数据基,每个网页仅显示一个<编码>数据框架>代码>。 我谨以标准11x8.5纸张尺寸将每个<代码>(有多个数据机)打印到一个pdf文档。 我想能够把纸张宽度中的26栏和长效的数值放在多页上,因为下几页是继续使用。 你是否有任何建议?
import streamlit as st
import pandas as pd
import numpy as np
# Initialize session state with dataframes
# Include initialization of "edited" slots by copying originals
if df1 not in st.session_state:
st.title("**:blue[Title123]**")
Nvals = 200
rows = [ a{} .format(i) for i in range(1, Nvals+1)] # a1:a19
values = np.arange(Nvals)
st.session_state.df1 = pd.DataFrame({
"rows/cols": rows,
A : list(range(Nvals)), B : list(range(Nvals)), C : list(range(Nvals)), D : list(range(Nvals)), E : list(range(Nvals)),
F : list(range(Nvals)), G : list(range(Nvals)), H : list(range(Nvals)), I : list(range(Nvals)), J : list(range(Nvals)),
K : list(range(Nvals)), L : list(range(Nvals)), M : list(range(Nvals)), N : list(range(Nvals)), Q : list(range(Nvals)),
O : list(range(Nvals)), P : list(range(Nvals)), R : list(range(Nvals)), S : list(range(Nvals)), T : list(range(Nvals)),
U : list(range(Nvals)), V : list(range(Nvals)), W : list(range(Nvals)), X : list(range(Nvals)), Y : list(range(Nvals)), Z : list(range(Nvals)),
})
st.session_state.edited_df1 = st.session_state.df1.copy()
#
st.session_state.df2 = pd.DataFrame({
"col1": ["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10"],
"Values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"col2": ["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10"],
"Values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
"col3": ["b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10"],
"Values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
})
st.session_state.edited_df2 = st.session_state.df2.copy()
# Save edits by copying edited dataframes to "original" slots in session state
def on_change_callback_fcn():
st.session_state.df1 = st.session_state.edited_df1
st.session_state.df2 = st.session_state.edited_df2
# Sidebar to select page and commit changes upon selection
page = st.sidebar.selectbox("Select: ", ("A","B"), on_change=on_change_callback_fcn, key= SelectedSelectboxVal )
# Convenient shorthand notation used below in funct1 and funct2
def funct1():
st.session_state.edited_df1 = st.data_editor(st.session_state.df1, num_rows="dynamic",height=10*len(st.session_state.edited_df1))
def funct2():
st.session_state.edited_df2 = st.data_editor(st.session_state.df2, num_rows="dynamic")
if page == "A":
st.header("Page A")
funct1()
elif page == "B":
st.header("Page B")
funct2()
print(
......................
Entire Code Ran
......................
)
print(len(st.session_state.edited_df1))
<代码>Ctrl+Pt=t work。 我没有找到这方面的许多在线材料。