✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Error: options[].label in Dropdown .. is required but it was not provided

Hi all,

I have a problem with my Dashboard. When I Start the Dashboard the Browser showes following Error:

“option[10].label in Dropdown with ID “Test_Temp” is required bit it was not provided” (This error originated from built-in JavaScript code that runs Dash apps."

(This error is also for two other Dropdowns, but the rest works fine)

My problem is, that this only appears on an other PC. (Same Chromebrowser version). On my PC there are no errors at all.

Doesnt work:

sd.Paper([html.Div([
html.Label(’ Test Temperature Filter’,style={‘color’: ‘#283e3e’, “family”: “Helvetica Neue, monospace”, “fontSize” : ‘18px’}),
dcc.Dropdown(id=‘Test_Temp’,
options=[{‘label’:i, ‘value’:i} for i in df[‘RTB_Test_Temp’].unique()],
multi = True,
className = ‘Dropdown’,
value = df[‘RTB_Test_Temp’].unique()),
spacer
], style={‘marginBottom’: 10, ‘marginTop’: 2, ‘marginLeft’: Border_left,‘marginRight’: Border_right})],zDepth=Depth),

Works:

sd.Paper([html.Div([
html.Label(’ Testvariant Filter’,style={‘color’: ‘#283e3e’, “family”: “Helvetica Neue, monospace”, “fontSize” : ‘18px’}),
dcc.Dropdown(id=‘Testvariant’,
options=[{‘label’:i, ‘value’:i} for i in df[‘RTB_Testvariant’].unique()],
multi = True,
className = ‘Dropdown’,
value = df[‘RTB_Testvariant’].unique()),
spacer
], style={‘marginBottom’: 10, ‘marginTop’: 2, ‘marginLeft’: Border_left,‘marginRight’: Border_right})],zDepth=Depth),

Has anybody an idea what could be the issue here?

Summary:

  • Dashboard works on my PC fine, same Dashboard has errors at an other pc
  • Some Dropdowns work, some do not

(Sorry for my english, its not my native language)

1 Like

Hi all,

FYI: I found and fixed the problem even if i do not understand why this is an issue on other PC’s but not on mine.

In my Dataframe there are some rows which include empty parts. E.g.: Value1,Value2 ,Empty, Value4…
This empty parts are translated to NaN by pandas and this causes the errors. When I replace all NaN by an value everything works fine.

e.g.

df[‘RTB_Test_Temp’] = df[‘RTB_Test_Temp’].fillna(9999)

3 Likes

I wanted to let you know that I had the same issue. With your helped I’ve managed to fix it. Thanks!

1 Like

I think the new version of dash doesn’t allow null values as they were ok in dropdown menus before. When building your dropdown menu options you can filter out the null values. Here is an example of how I did that using a function that takes the dataframe and columns as inputs.

def generate_options(dftemp,col):
    tempdict = defaultdict(int)
    for val in dftemp[col]:
        if val:
            tempdict[val]+=1
    temp_options = []
    for tup in sorted(tempdict.items(),key=lambda x:x[1],reverse=True):
        temp_options.append(dict(label=str(tup),value=tup[0]))      
    return temp_options