Use return variable in functions or st.session_state

I am just starting to learn streamlit and i am very excited since it was the first time i could manage to run a web app from scratch. I would like to know something about the design of the apps. I am working with several dataframes in pandas and each function returns the dataframe after some transformation. My question is, should i return those values via return function variables (to feed another function or display to user) or is it better to use st.session_state to use those variables as a global variable throughout the code ? Thanks in advance and congrats for the developers team. Amazing framework.

I try to use session variable if it is really needed. The idea is to minimize storing things in the session state.

Hi @machadolopes

Starting out, if the app works without session state, perfect. I wouldnโ€™t worry about using session state as long as it works. However, if youโ€™re app is reloading with every widget interaction and the state is lost and you want to avoid this, then using session state may help.

Hereโ€™s a bit more info on Session state in the Docs:

Hope this helps!