Setting selected rows of st.dataframe from session states

We have an st.dataframe where users can select rows from the table.

Whenever users come back to the page from another page, we want to set the selected rows of the st.dataframe and display them on the page.

Below is the code, but there is no doc on how to do that


import numpy as np

df = pd.DataFrame(
        np.array([['a1','b1'],['a2','b2']]), columns=["a", "b"]
    )

st.dataframe(
    df,
    on_select="rerun",
    selection_mode=["multi-row"],
)

any idea?

Currently Streamlit does not support what you have described.

A workaround is to use the data editor. You need to create a column where the users may select.