Hi Friends!
I have been working with st.data_editor() a bit. I just use “new_df = st.data_editor(df)” and thats pretty much it…
When the user is continuously making changes, should I pass the new_df again to the st.data_editor?
I somehow think I am sometimes getting stale values when I make multiple edits. Its a bit confusing. Can one of you confirm if this reliably works?
Is pressing “enter” mandatory while inputting values? (or) can I just click outside the editor frame and expect values to be reflected?
What actions/interactions of the user trigger a new run?
Thanks for any help.
@ferdy Can you help me with some info on this? Thanks!
Off the top of my head, I think:
- No, that’s not necessary. It should preserve the latest edits automatically while the user is editing.
- It’s hard to answer this without seeing a small, reproducible code snippet.
- No, clicking outside the editor should work fine.
- Any edits, insertions or deletions should trigger a new run.
2 Likes
Thank you very much for your answers.
If I can repro any weird behavior, I will post here. Thanks!
ferdy
5
Sample case.
- Create a dataframe from csv file.
- Load the dataframe in data editor.
- Make edits.
- Click Save to save the edited daframe to csv file.
- Back to step 1

import streamlit as st
import pandas as pd
csvfn = 'data.csv'
def update(edf):
edf.to_csv(csvfn, index=False)
load_df.clear()
@st.cache_data(ttl='1d')
def load_df():
return pd.read_csv(csvfn)
df = load_df()
edf = st.data_editor(df)
st.button('Save', on_click=update, args=(edf, ))
1 Like
Thank you very much @ferdy. That pretty much clears the air! Many thanks for your time!
system
Closed
7
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.