St.data_editor removes data frame after editing?

Summary

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

streamlit==1.23.0
pandas
requests
stripe
peopledatalabs

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