How to create expanders for multiple columns?

i am trying to create function that display 12 columns that have expander and each expander have a multiselect widget with table.

How can i do this ?

my code:


def display_month_list(df,month):
      df_test = df.iloc[:;[0,1,2,3]]
      option_list = df_test["categories"].unique().tolist()
     
      selected_option = st.multiselect("Select Category",option_list)
      if selected_option:
            df_test = df_test[df_test["categories"].isin(selected_option)]
      st.write(df_test)

col1,col2,col3,col4 = st.columns(4)
col5,col6,col7,col8 = st.columns(4)
col9,col10,col11,col12 = st.columns(4)

with col1:
   with st.expander("cat1"):
        display_month_list(df,"cat1")

with col2:
   with st.expander("cat2"):
        display_month_list(df,"cat2")

and so on…

My question is how to add this function in each column?

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