Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

TypeError that I don't understand in an app

Hello everyone,

I have an error message when I run an app and I do not understand why I got this one. I use the same type of code in another part of the application and I do not have this issue.

What I want to do:
1- Select an item using a dcc.RadioItems
2- Make a selection of several values within the selected RadioItem, using a multiple dcc.Dropdown
3- Make a graph of all values of a third column, using the data coming from the Dropdown.

Here’s what I’ve got:

I do not get why. I’m using the right syntax I think (df2 = df[df["…"].isin(…)]). I’m using the exact same code in another part of the app, using the exact same dataframe, and I do not have errors.
Plus, even if I have this error message, I get my graph at the end, so basically it’s working.

The only thing that I do different is that I make an if/elif statement to select the data coming from my Radio Items selection. A part of my code (app.callbacks only) is available below. I used some codes coming from the Dash guide, maybe I did something wrong?

# Selection of the type to analyse (group, subgroup, or product)
    Output('tab3_dropdown', 'options'),
    Input('tab3_radioitem', 'value')

def set_cities_options(selected_country):
    return [{'label': i, 'value': i} for i in available_lists[selected_country]]

# Select the group(s), subgroup(s) or product(s)
    Output('tab3_dropdown', 'value'),
    Input('tab3_dropdown', 'options')

def set_cities_value(available_options):
    return available_options[0]['value']

# Group graph 1 
    Output('tab3_graph_1', 'figure'),
    Input('tab3_radioitem', 'value'),
    Input('tab3_dropdown', 'value')

def callback_tab3_graph_1(selected_radioitem, selected_group_1):
    if selected_radioitem == "Groups":
        tmp_graph_1 = etapes[etapes["Groupe d'aliment"].isin(selected_group_1)]
    elif selected_radioitem == "Subgroups":
        tmp_graph_1 = etapes[etapes["Sous-groupe d'aliment"].isin(selected_group_1)]
        tmp_graph_1 = etapes[etapes["Nom du Produit en Français"].isin(selected_group_1)]    
    tmp_graph_2 = pd.DataFrame(tmp_graph_1.sort_values(by=["Groupe d'aliment", "Sous-groupe d'aliment", "Nom du Produit en Français"]))
    tmp_graph_3 = pd.DataFrame(tmp_graph_2.rename(columns={"Total" : "PEF"})) 
    comp_fig_6 =, x="Nom du Produit en Français", y="PEF", color="Nom du Produit en Français", title='Score PEF', barmode="group")
    return comp_fig_6

I’m definitely sure the issue comes from the third callback (# Group graph 1), cause when I remove this one I do not have any error anymore.

Do you have an advice to help me fix this? Again, when I do my selections it’s working in the end (see below the ice creams).

Thank you very much,

Hi Alpy,

The error message is saying that the function isin() must be used with a list and instead you are passing a string.
Check the element that you have into the isin().