I’m using st.autorefresh for updating my dashboard in streamlit, but it was taking too much time to refresh the dash. So I read about @st.cache_data, but when i used in code where my funtion or file/dataframe is save then im getting syntax error for code below @st.cache_data.So what to do. My objective is to reduce run time. If I get solution on that will be helpful.
What code below?
suppose my code is:
import numpy as np
import pandas as pd
import warnings
warnings.filterwarnings(“ignore”)
### Creating dataframe to store required data
@st.cache_data(ttl=60)
In[4]:
df1_config=pd.read_excel(“excel_to_python.xlsx”, sheet_name=‘config_data’)
so its showing error for df1_config as invalid syntax. If I removed st.cache then its working fine.
That is indeed invalid syntax. Check the examples in the docs to learn how to use cache_data.
can you give me correct syntax, i may not be understand doc as im from non tech background. Thank you
In the code you posted there is nothing to cache so just remove @st.cache_data(ttl=60).
In your actual code… how would I know?
ok, got it
is there any other way to reduce the run time? its taking too much time to run