I figured it out. Function display_table
needs to be changed to this:
def display_table(dropdown_country, dropdown_state):
if dropdown_country is None and dropdown_state is None:
return generate_table(stats_df)
if dropdown_country is not None and dropdown_state is not None:
stats_dff = stats_df.loc[(stats_df.COUNTRY.str.contains('|'.join(dropdown_country))) & (stats_df.STATE.str.contains('|'.join(dropdown_state)))]
return generate_table(stats_dff)
if dropdown_country is not None:
stats_dff = stats_df.loc[stats_df.COUNTRY.str.contains('|'.join(dropdown_country))]
return generate_table(stats_dff)
if dropdown_state is not None:
stats_dff = stats_df.loc[stats_df.STATE.str.contains('|'.join(dropdown_state))]
return generate_table(stats_dff)