Update a graph with a column in a dataframe selected by dropdown


I’ll try to do that. I have a dataframe, and in my dropdown I have the columns headers.

options = [col1, col2, col3…]

dcc.Dropdown (id=test, options = options),

Output(“testg”, “figure”),
[Input(“test”, “value”),

def update_fig(value):
trace = go.Scatter(x=(df.time),
y= df [‘value’],

But didnt works, how to select the y in function of column, selected by dropdown?

Thx so much1


Welcome to the community!

Try to use value unquoted in y=df[value]. Just be aware that value can be None when the app starts, so this has to be handled somehow (preventing the initial call or handling a none explicitly in the callback).

So many thx!!!. WORKS! :smiling_face: