Summary
Iam trying to use filters on a dataframe that is getting dynamically updated in the code, but whenever iam trying to select a filter the code is getting rerun and the data is getting updated in the dataframe(new rows are getting added). i want a solution to stop the rerun
Code snippet:
inactive_components =
component_names=“,”.join(inactive_components)
df1.loc[len(df1)] = [date_formatted,time_formatted,len(inactive_components),component_names]
@st.cache_data
def get_filtered_df(df1,_option1,_option2):
return _df1[_df1[_option1] == _option2]
with st.sidebar:
st.subheader(“Filter dataframe1”)
filtered_df = dataframe_explorer(df)
st.divider()
option1 = st.selectbox(“select column names”, list(df1.columns))
option2 = st.selectbox(“select values”, list(set(df1[option1])))
filtered_df1 = get_filtered_df(df1,option1,option2)
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
so whenever there is a filter being applied the dataframe should be displayed with filters applied and there shouldnt be any new data added.
Actual behavior:
but whenever i try to select filters,the dataframe is getting updated
Debug info
- Streamlit version: 1.21.0
- Python version: Python 3.11.2
- Using PyEnv
- OS version:
- Browser version: