I will try to explain the title with a .gif :

Here is the code used :
#https://stackoverflow.com/posts/76562670
import streamlit as st
import pandas as pd
df = pd.DataFrame({"col": ["foo", "baz", "qux"]})
st.data_editor(df, key="OK")
if st.button("Show another df"):
st.data_editor(df, key="KO")
Can you help me fix that, please ?
Hi @Rendezvous,
Thanks for posting!
Just to verify, are you trying to get the changes from the original table to propagate to the next table when you click Show another df?
Hi @tonykip, thanks for your reply. The two dataframes are completely indenpendent. I used two in my example just to show that when using st.data_editor inside an if st.button(): bloc, the behaviour changes. I posted a solution in SO. Can you tell me if it’s the right way to do it, please ?
Since the data editor is a widget the causes a rerun, nesting it under a button will cause it to disappear when you interact with it. Buttons don’t remain True through successive reruns.
Check out this new guide to buttons for explanations and snippets.