I am trying to change the value in a column based on changes made by the user in a different column with st.data_editor, and want to do it live on change. But the following code only works after 2 changes and only shows the initial change.
code is run by running streamlit run main.py
main.py
from page import pagepage()page.py
import streamlit as stimport pandas as pdboq_df = pd.DataFrame()def update_dataframe(): boq_df.loc[boq_df["ANALYZE"] == False, "TYPE"] = None boq_df.ffill(inplace=True)def page(): global boq_df st.write("# Test") if st.button("Analyze", type="primary"): boq_df = pd.DataFrame( data={"ANALYZE": [True, False, True],"CAT": ["Car", "Truck", "Bike"],"TYPE": ["blue", False, "yellow"],"DESC": ["two door", "four door", "single"], } ) if not boq_df.empty: boq_df = st.data_editor(boq_df, height=700, on_change=update_dataframe())