How do i create a filter based on the input received from a selectbox?

I’m getting nine inputs from a select box, then I should create a new data frame based on the values of the input. Below is my code, but it is not working and throwing an error. Can anyone help?


df = pd.read_csv(path)

df
data_source = df['source'].unique()
loan_type = df['loan_program'].unique()
loan_purpose = df['loan_purpose'].unique()
product = df['product'].unique()
loan_amount = df['loan_amount'].unique()
ltv = df['ltv'].unique()
credit_score = df['credit_score'].unique()
state = df['state'].unique()
geography = df['geography'].unique()




drop_down = st.sidebar.selectbox('Select a data source', data_source)
loan_type_drop_down = st.sidebar.selectbox('Select a loan type', loan_type)
loan_purpose_drop_down = st.sidebar.selectbox('Select a loan purpose', loan_purpose)
product_drop_down = st.sidebar.selectbox('Select a product', product)
loan_amount_drop_down = st.sidebar.selectbox('Select a loan amount', loan_amount)
ltv_drop_down = st.sidebar.selectbox('Select a ltv', ltv)
credit_score_drop_down = st.sidebar.selectbox('Select a credit score', credit_score)
state_drop_down = st.sidebar.selectbox('Select a state', state)
geography_drop_down = st.sidebar.selectbox('Select a geography', geography)


df_selected = df[df['source'] == drop_down] & df[df['loan_program'] == loan_type_drop_down] & df[df['loan_purpose'] == loan_purpose_drop_down] & df[df['product'] == product_drop_down] & df[df['loan_amount'] == loan_amount_drop_down] & df[df['ltv'] == ltv_drop_down] & df[df['credit_score'] == credit_score_drop_down] & df[df['state'] == state_drop_down] & df[df['geography'] == geography_drop_down]

df_selected