Hello everyone, i’m creating an application where users can import a list of names and the app will find similar names to link with, the user can select the name that they find the most similar. It will go trough the imported data 1 by 1 and there’s a selectbox with the suggested matches. Once a match is made this will append to a new dataframe.
However, my app is not doing what i want it to do, when i click “next” on the button it shows the last added row of the new dataframe. When i select an option, it goes to the next row. I don’t know how this happens, maybe it has something to do with caching?
Steps to reproduce
if 'row' not in st.session_state: st.session_state.row = 0 if 'data_new' not in st.session_state: st.session_state.data_new =  data_li =  col1, col2 = st.columns([5, 5]) with col1: st.dataframe(df) with col2: if st.session_state.row < len(df): pid = df["id"][st.session_state.row] pname = df["name"][st.session_state.row] pweight = df["weight"][st.session_state.row] tmatch = df["text_matches"][st.session_state.row] data_li.append([pid, pname, pweight]) else: st.error("reached end of the file") st.dataframe(data_li) selection = st.selectbox('Select most similar product: ', options=tmatch + ['Product not found...']) approved = st.button("Next") if approved: st.session_state.row += 1 st.session_state.data_new.append([pid, pname, pweight, selection]) print(st.session_state.row) st.dataframe(st.session_state.data_new)
- Streamlit version: 1.10.0
- Python version: 3.6.4