I am currently trying to use the selectbox to allow the users to pick a name of a column to run a model with. When I put a selectbox in the sidebar I didn’t have an issue, but when I put the selectbox on the main page as soon as the user selects a option the wepage resets. the code is below. I am still new to streamlit, so I am not sure if I am using this properly. I appreciate the help!
#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)