Python Streamlight selectbox正在重置网页
我目前正在尝试使用selectbox来允许用户选择要运行模型的列的名称。当我在侧边栏中放置一个选择框时,我没有问题,但是当我在主页上放置选择框时,只要用户选择一个选项,网页就会重置。代码如下。我对Streamlight还是新手,所以我不确定我是否正确使用了它。我感谢你的帮助Python Streamlight selectbox正在重置网页,python,drop-down-menu,streamlit,Python,Drop Down Menu,Streamlit,我目前正在尝试使用selectbox来允许用户选择要运行模型的列的名称。当我在侧边栏中放置一个选择框时,我没有问题,但是当我在主页上放置选择框时,只要用户选择一个选项,网页就会重置。代码如下。我对Streamlight还是新手,所以我不确定我是否正确使用了它。我感谢你的帮助 #add a blank space in the columnName section columnNames = [" "] #grab the column names of the datafr
#add a blank space in the columnName section
columnNames = [" "]
#grab the column names of the dataframe
for column in df.columns:
columnNames.append(column)
#place the selectboxe in the col1 slot
with col1:
#display the column names to the user
#So that they can select the columns they want to use
columnValue = st.multiselect("Select the column:", columnNames)
#place a button in col2 slot
with col2:
#a button to add the selected column to a list of want to use columns
addButtonList = st.button("Add to select list: ")
#when 'addButtonList' is selected take the value from
#'columnValue' and place it on the screen.
if(addButtonList):
st.write(columnValue)
似乎有一种方法可以将
session\u状态设置为按钮。检查此项或查看详细说明。似乎有一种方法可以将会话状态设置为按钮。请勾选此项或查看详细说明