Im trying to build an app where user can exclude or include data points through a st.data_editor. The changes are being reflected after every other action. Any idea as to why?
The code is as below:
if option=='Data Header':
prev_tab = st.session_state.prev_tab
st.session_state.prev_tab = option
st.write(prev_tab)
if prev_tab=='Data Header':
if st.session_state['data_header_df'] is not None:
df = st.session_state['data_header_df']
else:
if st.session_state['file_path'] is not None:
df = pd.read_csv(st.session_state['file_path'])
df.columns = [i.upper() for i in df.columns]
else:
st.warning("File type Not supported")
df = data_cleaning(df)
df['EXCLUDE/INCLUDE'] = True
elif prev_tab=='Data Statistics':
if st.session_state['histogram_df'] is not None:
df = st.session_state['histogram_df']
else:
df = st.session_state['data_header_df']
elif prev_tab=='Correlation Matrix':
if st.session_state['corr_df'] is not None:
df = st.session_state['corr_df']
else:
df = st.session_state['histogram_df']
elif prev_tab=='Plot':
if st.session_state['filter_df'] is not None:
df = st.session_state['filter_df']
else:
df = st.session_state['corr_df']
with stylable_container(
key='h3',
css_styles="""
h3 {
font-size: 16px;
}
"""
):
st.subheader('Header of the DataSet')
c01, c02, c03 = st.columns(3)
with c02:
select = st.checkbox('Select All')
with c01:
deselect = st.checkbox('Deselect All')
if select:
df['EXCLUDE/INCLUDE'] = True
if deselect:
df['EXCLUDE/INCLUDE'] = False
df = st.data_editor(
df,
column_config={
"Exclude/Include": st.column_config.CheckboxColumn()
},
use_container_width=True,
hide_index=False,
height=350,
)
st.session_state['data_header_df'] = df
Link to the website is :
Webpage
Choose a dataset then click next, the table is displayed try clicking on two checkboxes youll see the error