Greetings
I am trying to use a dictionary as labels and values in a dcc.dropdown component. My dictionary is something like this:
{1: 'Australian Grand Prix',
2: 'Bahrain Grand Prix',
3: 'Chinese Grand Prix',
4: 'Azerbaijan Grand Prix',
5: 'Spanish Grand Prix',
6: 'Monaco Grand Prix',
7: 'Canadian Grand Prix',
8: 'French Grand Prix',
9: 'Austrian Grand Prix',
10: 'British Grand Prix'}
I am trying to use the keys of the dictionary as the values of the dropdown component, and values of the dictionary as labels. I am doing this, as the keys are more important to a callback I will write, than the race names(values of the dictionary)
I have tried the following code:
dcc.Dropdown(id = "rounds",
options=[
{'label': list(Laps.year_round_drivers(2019)["round"].values()),
'value': list(Laps.year_round_drivers(2019)["round"].keys())}
],
value = Laps.round,
multi = True)
Where, Laps.year_round_drivers(2019)["round"]
is the dictionary described above.
The dash app starts up and the following error is thrown:
Invalid argument
options[0].label passed into Dropdown with ID "rounds".
I have also tried:
dcc.Dropdown(id = "rounds",
options=[
{'label': Laps.year_round_drivers(2019)["round"][i],
'value': i} for i in Laps.year_round_drivers(2019)["round"].keys()
],
value = Laps.round,
multi = True)
which throws the same error.
Any help would be appreciated. Thank you.