St.data_editor removes data frame after editing?


I have loaded a dataframe into the st.data_editor ok. When I edit the data in any column, the table suddenly disappears…

Steps to reproduce

Code snippet:

          st.write("People Search Results")

          # Create a DataFrame
          df = pd.DataFrame(people_data,
                            columns=['Name', 'Title', 'LinkedIn URL'])
          # Add an "Enrich" column with unchecked checkboxes
          df.insert(0, 'Enrich',
                  [False] * len(df))  # Insert at the first position

          # Display the editable dataframe
          st.data_editor(df, key="data_editor", hide_index=True)

          # Check for changes in the session state
          # changed_data = st.session_state.get("data_editor", {})
          st.write(st.session_state["data_editor"])  # Debug print

Expected behavior:

I expect the table to stay on the page and the amended rows to appear underneath where I’m writing them.

Actual behavior:

The table/data disappears…

Debug info

  • Streamlit version: 1.23
  • Python version: 3.10.8

Requirements file


I am having the same issue

I’m having an issue like this. I edit a dataframe in data_editor, and every time I edit a cell, the dataframe reloads for a few seconds. I’d like to be able to edit the dataframe quickly, without having to wait between each cell. Does anyone have an idea of how to do this so that the dataframe isn’t searched for each cell?

You can put it in a form so that it doesn’t retrigger the script

1 Like

Thank you !!!
I’ve been working on it for days and I can’t find a solution. I hadn’t thought of simply putting it in a st.form.

1 Like

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