【问题标题】:Streamlit selectbox is reseting the webpageStreamlit 选择框正在重置网页
【发布时间】:2021-02-27 17:40:59
【问题描述】:

我目前正在尝试使用选择框来允许用户选择列的名称来运行模型。当我在侧边栏中放置一个选择框时,我没有遇到问题,但是当我将选择框放在主页上时,只要用户选择一个选项,网页就会重置。代码如下。我还是流光新手,所以我不确定我是否正确使用它。感谢您的帮助!

#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)

【问题讨论】:

    标签: python drop-down-menu streamlit


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-17
      • 2021-09-02
      • 2021-12-29
      • 2022-11-16
      • 2012-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多