Data Editor bug when used in a streamlit form

Hi!

I wanted to use a data editor inside of a form but I am running into a bug. Here is a mock example of my code:

df2 = pd.DataFrame([
    {"ID": 1, "NAME": "Guillaume"}, 
    {"ID": 2, "NAME": "Tim"}, 
    {"ID": 3, "NAME": "me"},
    {"ID": 4, "NAME": "aname2"},
    {"ID": 5, "NAME": "aname"}
])
df2["NAME"] = df2["NAME"].astype("string")


with st.form(key="edit_table2"):
    new_df2 = st.data_editor(df2, num_rows="dynamic", key="new_df2")
    submitted = st.form_submit_button("Submit2")

st.write(new_df2)

Unfortunately when I

  1. Add a row
  2. Modify a row
  3. Delete a row

The data editor does not register all my changes. Please see the video:

Additional info:

  1. The app is running locally
  2. No error message is displayed
  3. Streamlit 1.44.1, Python 3.11

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.