How can I add the graphs under selectbox?

I want to make a st.selectbox with the code below.
When I select Males vs Females, it shows that graph.
How can I put those code under selectbox?

st.write('Males vs Females')
gender_count = my_pop.groupby('Offences')['Males', 'Females'].sum()
gender_count.columns = ['Males','Females']
st.bar_chart(data = gender_count, use_container_width=True)

st.write('Adults vs Juveniles')
gender_count = my_pop.groupby('Offences')['Adults', 'Juveniles'].sum()
gender_count.columns = ['Adults','Juveniles']
st.bar_chart(data = gender_count, use_container_width=True)

Hi @Jisu_Lee

Did you try to use a conditional statement with the session state ?

if st.session_state.selectbox_id == 'Males vs Females':
  """Your Males vs Females bloc"""
elif st.session_state.selectbox_id == 'Adults vs Juveniles':
  """Your Adults vs Juveniles bloc"""

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.