Hi,
i have. a program that is doing something like that but after:
- Clicking on update
- When changing the period selectbox, I need to click on update again to print the code after the selectbox option.
How should I do if I do not want that ie the Update data button update the data and while I do not click on this button, the calculation, will continue with the df dataframe that was loaded at the previous click ?
@st.cache_data
def load_data(google_data_load=True):
# Calculation
return df
# Button to load data
if st.button("Update", type='primary'):
df = load_data()
st.dataframe(df)
.... # Stuff are done here
periode = st.selectbox('Period',
['6 mois', '1 an', '3 ans'],
index= 1
)
if periode=='6 mois':
lag = 126
elif periode=='1 an':
lag = 252
else:
lag = 3*252
st.dataframe(histo
.pct_change()
.rolling(lag)
.apply(lambda x: 100*cagr(x))
.dropna()
)