0

I have a DataFrame in pandas called interesttable, which is getting updated with time (seconds). I am using Dash plotly to display the dataframe. Although i successfully display the dataframe in Dash, I cannot update the Dash with the new rows added in the dataframe. I try the following but it doesn't work. Thank you for your feedback!

def generate_table():
    return html.Table(
    # Header
    [html.Tr([html.Th(col) for col in interesttable.columns])] +

    # Body
    [html.Tr([html.Td(interesttable.iloc[i][col]) for col in interesttable.columns])
    for i in range(min(len(interesttable), 50))]

    )


app = dash.Dash()

app.layout = html.Div(children=[

html.H1(children='Interest Table'),
dcc.Interval(id='generate_table()',interval=1*1000),

generate_table()

])

app.callback(Output('generate_table()','children'), [Input('interesttable', 'n_intervals')])


if __name__ == '__main__':
app.run_server(debug=True)

Unfortunatelly the error I receive is:

 Here is a list of the available properties in "generate_table()":
 ['id','interval','disabled','n_intervals','max_intervals']

1 Answer 1

1

Isn't app.callback supposed to be a decorator?

Try:

@app.callback(Output('generate_table()','children'), [Input('interesttable', 'n_intervals')])

I don't see also n_intervals declared.

You should add it:

app.layout = html.Div(children=[html.H1(children='Interest Table'), dcc.Interval(id='generate_table()',interval=1000,n_intervals=0 ),generate_table()])

Sign up to request clarification or add additional context in comments.

1 Comment

That makes sense to do it like this. Without the dcc.Interval, the generate_table() is only called once during application startup

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.