St.write or st.success not working on Button click


I am trying to run a code on button click, the code is running fine but st.success or st.write methods are not displaying any value. Below is my code:

state.orgnl_rem_z_score = st.multiselect("Select list of variables",preproc.fetch_numeric_cols(state, data_select, numeric_dtype),state.orgnl_rem_z_score)
        if st.button("Remove Outlier by Z-Score"):
                z = np.abs(stats.zscore(state.df[state.orgnl_rem_z_score]))
                state.df = state.df[(z < 3).all(axis=1)]

Let me know if anyone can help me with this.

Thanks in advance !!!

Hi @anshul -

The first thing that sticks out to me is why are you using a try statement? Meaning, what sort of possible error are you expecting to happen?

If I had to guess, I suspect your code is erroring, sending you to the except branch and printing nothing. Put something in the except section like "this code failed" and see what branch you are in.


I have tried by writing something in except section. I have used try and catch because I thought my code is going into except statement but that is not happening. Entire code present in Try is running successfully just that message is not getting displayed.