Any good reference/example links of example of master detail st.dataframes
when we select a row in master df
below all the detail rows should be displayed.
Thanks
Sai
If you’re just looking for a generic example, here’s one:
import pandas as pd
import streamlit as st
data = [
{
"name": "Bob",
"age": 13,
"grades": {
"Math": 100,
"English": 90,
"Science": 80,
},
},
{
"name": "Alice",
"age": 12,
"grades": {
"Math": 90,
"English": 80,
"Science": 70,
},
},
{
"name": "Charlie",
"age": 11,
"grades": {
"Math": 80,
"English": 70,
"Science": 60,
},
},
]
df = pd.DataFrame(data)
overall_data = df[["name", "age"]]
selected_row = st.dataframe(
overall_data, on_select="rerun", selection_mode="single-row"
)
try:
row_id = selected_row["selection"]["rows"][0]
except IndexError:
st.write("Select a row above to see more detail")
st.stop()
row = data[row_id]
grades = row["grades"]
st.write(f"Grades for {row['name']}")
st.dataframe(grades, hide_index=True)
See it on the playground here:
TYSM… Thank you so much ![]()