How to get st.data_editor selected row data in new dataframe

hi boss
I kindly request your guidance on how to transfer the selected row data from st.data_editor to a new DataFrame. I would appreciate it if you could provide me with the appropriate code. Thank you in advance for your assistance.

Try looking at this tutorial: Get dataframe row-selections from users - Streamlit Docs

In particular you can see where row data is used to filter a new dataframe. From the tutotial:

    event = st.dataframe(
        df,
        column_config=column_configuration,
        use_container_width=True,
        hide_index=True,
        on_select="rerun",
        selection_mode="multi-row",
    )
    people = event.selection.rows
    filtered_df = df.iloc[people]

thank you boss for your reply
see my code
wity your code
this is error name ‘column_configuration’ is not defined
column_config=column_configuration, # this line give the error
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},
]
)

edited_df = st.data_editor(df, num_rows=“dynamic”)

favorite_command = edited_df.loc[edited_df[“rating”].idxmax()][“command”]
st.markdown(f"Your favorite command is {favorite_command} :balloon:")
st.write(edited_df[“rating”].idxmax())

event = st.dataframe(
df,
column_config=column_configuration, # this line give the error
use_container_width=True,
hide_index=True,
on_select=“rerun”,
selection_mode=“multi-row”,
)

people = event.selection.rows
filtered_df = df.iloc[people]

boss this line give me error
column_config=column_configuration, # this line give the error
see error name ‘column_configuration’ is not defined

The full code is available in the linked tutorial. You can remove the column configuration.

I’m struggling here as well. The example is with the st.dataframe not with the st.data_editor which comes with select boxes already. What I’m looking for is a way to get the (indexes) of the selected rows. The selections are used by the component already to be able to delete the selected rows so should be possible to get the selected rows as well. Am I missing something?

If you only need row selections, I’d recommend st.dataframe. If you need other features of the data editor, the st.dataframe tutorial links to the older workaround using the data editor:

Hi there,

Thanks for the response. I will have a look but it seems to me that is just a matter of exposing the selected indexes. Like I mentioned in order to perform the deletion, the component already uses the selected rows. At least I would love to see this as a feature so that I can allow my users to do more complex edits in a different view.