Hi, I am pretty new to Dash. I want to select a value from the data frame with dropdown. Even if the program is running and I am getting what i want but I am getting “callback error updating output.children”. I am not able to fix it. Can anybody help?
Below is the code
Thanks,
df = pd.DataFrame({
‘x’: [1, 2, 3],
‘y’: [4, 1, 4],
‘z’: [1, 1, 1],
‘index’:[0,1,2],
})
app.layout = html.Div([
dcc.Dropdown(
id=‘dropdown’,
options=[{‘label’: i, ‘value’: i} for i in df[‘index’].unique()],
value=‘0’
),
html.Div(id=‘output’),
])
@app.callback(Output(‘output’, ‘children’),
[Input(‘dropdown’, ‘value’)])
def update_output_1(value):
filtered_df = (df[df['index'] == value])
filtered_df = (filtered_df['index'].values[0])
return 'You have selected "{}"'.format(filtered_df)
if name == ‘main’:
app.run_server(debug=True)