I have 9 inputs to a model that I allow my user to adjust, THEN they press a button to run the model (that way the model doesn’t try to run until every input has been updated). Once the model runs, I have a dataframe (model results) I display that I want to give the user the ability to filter with a multiselect, however, when I make a filter selection, it re-runs the script and resets back to before the button was pushed…
format of my code:
#function that runs my model @st.cache() def model_run() #I have eight number inputs that take different values to enter into the model st.sidebar.number_input() X 8 #button to run the model if st.button('Run Model'): model_results = model_run() #mutliselect to let user filter model run results options = st.multiselect("select a filter") new_df = model_results_df[model_results_df['Entity'].isin(options)] st.dataframe(new_df)
However, when I run the code above, when my user makes a selection, it reruns the script back to before I clicked my button and my output is lost.