Hi all !
I am currently writing a Streamlit dashboard, where I first want to fetch data from different sources and afterwards want to interactively analyze it. For the data downloading part I use st.from
so that my dashboard does not get refreshed on every change. However, combining the form with other interactive widgets seem to reset the dashboard every time. Is there a way around this? Here is some example snippet of my current approach:
import streamlit as st
DATA_SOURCES = {
'Postgres': [1, 2, 3, 4, 5],
'MySQL': [4, 2, 4, 2],
'Snowflake': [5, 4, 3, 2, 1]
}
def download():
with st.sidebar.form('download_form'):
source = st.selectbox('Select Data Source', ['Postgres', 'MySQL', 'Snowflake'])
if st.form_submit_button('Download Data'):
return DATA_SOURCES[source]
def multiplicator(vals):
multiplicator = st.radio('Select sampling', list(range(1, 5)))
return [val*multiplicator for val in vals]
if __name__=='__main__':
st.sidebar.header('Config Zone')
data = download()
st.header('Analyzing Zone')
if data:
new_data = multiplicator(data)
st.write(f'Initial data: {data}')
st.write(f'Multiplied data: {new_data}')
This is the current behaviour: