# Data\_editor fails to store new values after first new modifications:

**URL:** <https://discuss.streamlit.io/t/data-editor-fails-to-store-new-values-after-first-new-modifications/112424>\
**Category:** Using Streamlit\
**Tags:** bokeh, pandas, session-state, discussion\
**Created:** [May 13, 2025, 1:04pm UTC](https://discuss.streamlit.io/t/data-editor-fails-to-store-new-values-after-first-new-modifications/112424 "2025-05-13T13:04:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vital-Fernandez](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/vital-fernandez/32/47718_2.png) [@Vital-Fernandez](https://discuss.streamlit.io/u/Vital-Fernandez)\
**Post date:** [May 13, 2025, 1:04pm UTC](https://discuss.streamlit.io/t/data-editor-fails-to-store-new-values-after-first-new-modifications/112424/1 "2025-05-13T13:04:57Z")

</div>

Hi all,

I’m building a Streamlit app where I want users to edit a `pandas.DataFrame` via `st.data_editor()` and have a plot automatically update when the data changes.

Everything works _on first edit_, but subsequent changes often require **two edits** to be recognized, or they silently fail. This error reproduces the issue:

> ```
> import streamlit as st
> import pandas as pd
> import numpy as np
> import matplotlib.pyplot as plt
> 
> st.title("Live Plot from Editable DataFrame")
> 
> # Initialize session state only once
> if "df" not in st.session_state:
> st.session_state.df = pd.DataFrame({
> "x": np.arange(10),
> "y": np.random.randn(10)
> })
> 
> # Data editor (will auto-update and rerun when changed)
> edited_df = st.data_editor(
> st.session_state.df,
> key="editor_key",
> num_rows="dynamic",
> use_container_width=True,
> )
> 
> # Update stored DataFrame
> st.session_state.df = edited_df
> 
> # Plot the result
> st.subheader("Live-updated Plot")
> fig, ax = plt.subplots()
> ax.plot(edited_df["x"], edited_df["y"], marker='o')
> ax.set_xlabel("x")
> ax.set_ylabel("y")
> ax.grid(True)
> st.pyplot(fig)
> 
> ```

I wonder if anyone has a suggestion on how to manage this issue.

Thank you very much for any advice.

Kind regards

---

<div class="post-metadata">

**Author:** ![Goyo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/goyo/32/28219_2.png) [@Goyo](https://discuss.streamlit.io/u/Goyo)\
**Post date:** [May 13, 2025, 3:32pm UTC](https://discuss.streamlit.io/t/data-editor-fails-to-store-new-values-after-first-new-modifications/112424/2 "2025-05-13T15:32:13Z")

</div>

Delete this line

```python
st.session_state.df = edited_df

```

---

<div class="post-metadata">

**Author:** ![Vital-Fernandez](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/vital-fernandez/32/47718_2.png) [@Vital-Fernandez](https://discuss.streamlit.io/u/Vital-Fernandez)\
**Post date:** [May 13, 2025, 7:51pm UTC](https://discuss.streamlit.io/t/data-editor-fails-to-store-new-values-after-first-new-modifications/112424/3 "2025-05-13T19:51:40Z")

</div>

Thank you @Goyo ! That works without issues.

However, if I want the edited dataframe to replace the one in the session state: Is there a way to do it wihout bringing the issue?

---

<div class="post-metadata">

**Author:** ![Goyo](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/goyo/32/28219_2.png) [@Goyo](https://discuss.streamlit.io/u/Goyo)\
**Post date:** [May 13, 2025, 8:35pm UTC](https://discuss.streamlit.io/t/data-editor-fails-to-store-new-values-after-first-new-modifications/112424/5 "2025-05-13T20:35:14Z")

</div>

> [@Vital-Fernandez](#):
>
> However, if I want the edited dataframe to replace the one in the session state:

Why?

---

<div class="post-metadata">

**Author:** ![Vital-Fernandez](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/vital-fernandez/32/47718_2.png) [@Vital-Fernandez](https://discuss.streamlit.io/u/Vital-Fernandez)\
**Post date:** [May 14, 2025, 12:17am UTC](https://discuss.streamlit.io/t/data-editor-fails-to-store-new-values-after-first-new-modifications/112424/6 "2025-05-14T00:17:34Z")

</div>

In my [Streamlit app](https://specsy.streamlit.app/), each page builds on the results of the previous one. I want to keep the changes made to a DataFrame so that they’re available on the next page.
