Reputation: 103
I have a dropdown in Jupyter notebook filled with the values in a python list. I would like to replicate the same in Plotly-Dash.
Upvotes: 0
Views: 5631
Reputation: 103
I figured it out while I was at it. Put the list in a dataframe.
df= pd.DataFrame({
'c' : list
})
Code the dropdown
dcc.Dropdown(
id='dropdown',
options=[
{'label':i, 'value':i} for i in df['c'].unique()
],
),
html.Div(id='output')
Callback
@app.callback(Output('output', 'children'),
[Input('dropdown', 'value')])
def update_output_1(value):
filtered_df = df[df['c'] == value]
return filtered_df.iloc[0]['c']
Upvotes: 3