Filter Data in multiselect

I wanted know how to do i keep filtering the data when the user puts their own input. This is on the basis of the amazon sorting section , ie you get to put in your requirements and then youre presented with results based on your inputs
def app():

sd_ShutdownCode = [x[0] for x in rows]
sd_ShutdownCode = sorted(list(set(filter(None, sd_ShutdownCode))))

sd_Plant = [x[1] for x in rows]
sd_Plant = sorted(list(set(filter(None, sd_Plant))))

sd_region = [x[2] for x in rows]
df1 = (sd_region)
sd_region = sorted(list(set(filter(None, sd_region))))

reg_options = st.multiselect('Region', list(set(df1.iloc[:,'Region'])))

sd_CustomerLoc = [x[3] for x in rows]
sd_CustomerLoc = sorted(list(set(filter(None, sd_CustomerLoc))))

sd_Generations = [x[4] for x in rows]
sd_Generations = sorted(list(set(filter(None, sd_Generations))))

sd_Rootcause = [x[5] for x in rows]
sd_Rootcause = sorted(list(set(filter(None, sd_Rootcause))))  # removes nulls, followed by duplicates

sd_Replaced = [x[6] for x in rows]
sd_Replaced = sorted(list(set(filter(None, sd_Replaced))))  # removes nulls, followed by duplicates

sd_Category = [x[7] for x in rows]
sd_Category = sorted(list(set(filter(None, sd_Category))))  # removes nulls, followed by duplicates

#   sd_S-D Category = 'SELECT DISTINCT("S-D Category") FROM SD_Data WHERE  "S-D Category" IS NOT NULL'

# Popualting each line with two categories dropdown boxes

col1, col2 = st.columns(2) #Line1
with col1:
    reg_options = st.multiselect('Region', sd_region)

with col2:
    Generations_options = st.multiselect('Generations',sd_Generations)

col1, col2 = st.columns(2)  # Line2
with col1:
    ShutdownCodes_options = st.multiselect('Shutdown Codes',sd_ShutdownCode)

with col2:
    SD_Category_options = st.multiselect('SD Category',sd_Category)

col1, col2 = st.columns(2)  # Line3
with col1:
    Plant_options = st.multiselect('Plant',sd_Plant)
with col2:
    Customer_Location_options = st.multiselect('Customer Location',sd_CustomerLoc)

col1, col2 = st.columns(2) #Line4
with col1:
    Root_cause_options = st.multiselect('Root Cause',sd_Rootcause)
with col2:
    Components_Replaced_options = st.multiselect('Components Replaced', sd_Replaced)

this is my current code, i have used 1 cursor and 1 connection to sql as thats where im taking the data from .