Summary
Following the tutorial from st.data_editor - Streamlit Docs, I would like to learn how to delete the entire row within st.data_editor
Code Snipets
The following code was modified from st.data_editor - Streamlit Docs so that I can inspect its internal state.
import streamlit as st
import pandas as pd
df = pd.DataFrame(
[
{"command": "st.selectbox", "rating": 4, "is_widget": True},
{"command": "st.balloons", "rating": 5, "is_widget": False},
{"command": "st.time_input", "rating": 3, "is_widget": True},
]
)
def callback1(key_name):
st.write(st.session_state[key_name])
key_name = 'my_df'
edited_df = st.data_editor(
data=df,
num_rows="dynamic",
on_change=callback1,
args=[key_name],
key=key_name)
favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
st.markdown(f"Your favorite command is **{favorite_command}** π")
Observation 1: Modify existing column will alter the edited_rows
Observation 2: Add new row will alter the added_rows