Creating dependent columns without reloading in data_editor

Is it possible to have the one column change based on a change in the value of another column without ‘reloading’ the table/app? Or do we need to use a third party component and java script?

For example, I am currently defininig a function to be called on_change, this requires the table to be reloaded. Can this be done smoothly? E.G. below

def editor(): 

    if "df_cols" not in st.session_state:

        st.session_state\["df_cols"\] = df_cols

    st.data_editor(st.session_state\["df_cols"\], column_config=col_config, key = "df_editor",on_change=df_on_change)



editor()

on_change always causes a rerun, there is no partial DOM update; try the below

#import streamlit as st
#import pandas as pd

def df_on_change():
    df = st.session_state.df_cols

    # Example: column B depends on column A
    df["B"] = df["A"] * 2

    st.session_state.df_cols = df

def editor():
    if "df_cols" not in st.session_state:
        st.session_state.df_cols = pd.DataFrame(
            {"A": [1, 2, 3], "B": [2, 4, 6]}
        )

    st.data_editor(
        st.session_state.df_cols,
        key="df_editor",
        on_change=df_on_change,
        use_container_width=True
    )

editor()