Summary
Hello all,
I am experiencing unexpected behavior with the data_editor and session_state. Every second change to the data gets discarded.
I don’t think I really understand the session_state, so if this is expected behavior, I would appreciate an explanation.
Steps to reproduce
I have managed to reduce this bug (?) to 4 lines of code. A co-worker can reproduce it, too.
import streamlit as st
if 'df' not in st.session_state:
st.session_state.df = {'ID': [0, 1], 'name': ["a", "b"]}
st.session_state.df = st.data_editor(st.session_state.df)
- run example
- change a value in the table
- change a value in the table: this change does not get through and the data_editor reverts to the state after step 2
I have tried to debug this but I have no idea where to look. Steps two and three seem to execute the same code.
Expected behavior:
Changing any value in the data_editor should “stick”.
Actual behavior:
Every second change gets discarded.
Debug info
- Streamlit version: 1.23.1
- Python version: 3.11.3
- Using venv
- OS version: Win10
- Browser version: current Chrome and Opera
Additional information
I would love a data_editor-functionality to check and discard changes, but not like this