I’ve just started exploring Streamlit, so my apologies if my questions are somewhat basic.
I understand that Streamlit reexecutes my entire script after after user interaction.
My data is contained in a data frame with the following characteristics:
<class 'pandas.core.frame.DataFrame'> Index: 2641258 entries, 0 to 1495 Data columns (total 12 columns): # Column Dtype --- ------ ----- 0 Airport object 1 Terminal object 2 Date object 3 Time Range object 4 US Max Wait int64 5 Non US Max Wait int64 6 All Max Wait int64 7 Time object 8 Datetime datetime64[ns] 9 Year int32 10 Month object 11 Weekday object dtypes: datetime64[ns](1), int32(1), int64(3), object(7) memory usage: 251.9+ MB
Loading this from a (compressed) pickled file the first time takes about 5.5 seconds. The load routine is annotated with
@st.cache_data but still takes over 1.2 seconds to reload the data after each and every user interaction, which is rather slower than I was hoping for.
What’s the best practice approach to speeding up the user response, please?
(A version of the app, with less data, and hence a rather snappier response, is available at https://airportwaitingtimes.streamlit.app/)