How do I filter the df by the st.multiselect

How do I filter the df by the st.multiselect (beginner here).
Ignore the comments (past attempts)

df = pd.read_csv('./data/superbowl-ads.csv')
df = df.drop('use_sex', axis=1)
df = df.rename(columns={'year': 'Year', 'brand': 'Brand', 'superbowl_ads_dot_com_url': 'SBA URL', 'youtube_url': 'Youtube URL', 'funny' : 'Funny', 'show_product_quickly' : 'Quickly', 'patriotic' : 'Patriotic', 'celebrity' : 'Celebrity', 'danger' : 'Danger', 'animals' : 'Animals'})

#category_selection = st.multiselect('**Select categories**: ',category_list)

year_selection = st.slider('**Select year duration**: ', 2000, 2020, (2000, 2020))
df = df[(df['Year'] >= year_selection[0]) & (df['Year'] <= year_selection[1])]
#for category in category_selection:
#   if category 
category_list = ['Funny', 'Quickly', 'Patriotic', 'Celebrity', 'Danger', 'Animals']
#category_list = df[category].unique().tolist()
for category in category_list:

#df = df[df["Funny"].isin(category_selection)]    
    selected_options = st.multiselect('Which app do you want?', ['Funny', 'Quickly', 'Patriotic', 'Celebrity', 'Danger', 'Animals'])

    df = df[df[category].isin(selected_options)]

#if (category_selection[1]):
    
#df.query('Funny == True')


st.dataframe(df.style.format({"Year": str}))

Use the dynamic filter component

Sorry, newbie here. What does that mean? Is there a documentation page for it?

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