Env.
App: Local
Python: 3.11.9
Streamlit: 1.29.0
Hi, I’m trying to make a simple dashboard using streamlit.
When the data is inputted from the sidebar area, the main page will show two data frames due to the input result. I already splited it by st.columns
.
I’ll say the left area is the recom_area, and the right area is the result_area.
What I want to do, modify and show the DF right area (reseult_area
)
Sidebar (input area)
here, I make a data and stored it in input_data
. like this,
with st.sidebar:
# sudo: make some inputs (radio, text, num ...)
st.session_state.btn_search = st.button("Search") # searching button
if "input_data" not in st.session_state:
st.session_state.input_data = [# above inputs ...]
Main Pages (display area)
recom_area, result_area = st.columns(2)
with recom_area:
sim_pjt_info = Func(get some DF)
sim_pjt_cost = Func(get some DF)
# just have showing them
st.dataframe(sim_pjt_info.astype(str), height=320, width=700)
st.dataframe(sim_pjt_cost.astype(str), height=320, width=700)
with result_area:
# also just showing
input_info = Func(get some DF)
st.dataframe(input_info.astype(str).fillna(" "), height=320, width=700)
# !!! TO DO !!! - If I click the button, below DF should be change
recom_result = Func(get some DF, using sim_pjt_cost)
edit_df = st.data_editor(recom_result, ...)
#
reset_btn = st.button("Reset")
adj_btn = st.button("Adj")
# I edit the DF (first showing one),
if reset_btn:
# When I press reset button,
# the fix disappears and I have to go back to the beginning (recom_result)
if adj_btn:
# When I press adjust button,
# Create a new data frame using the modified data,
# and the existing data is updated with the newly created data, like this
new_edit_df = Func(edit_df) # modified
edit_df = new_edit_df # Same position as previously shown, edit_df = st.data_editor(recom_result, ...)
Is there a way to create a page in the above format?
I’ve tried this and that, but I couldn’t find a solution, I’d really appreciate your help.