TypeError: update_data() takes 1 positional argument but 2 were given
Недавно стала изучать dash app. и столкнулась с ошибкой:
Callback error updating body_div.children
Traceback: TypeError: update_data() takes 1 positional argument but 2 were given
Мой код:
df = pd.DataFrame(data)
table = dash_table.DataTable(
columns=[
{"name": col, "id": col, "selectable": True} for col in df.columns
],
data=df.to_dict('records'),
id='datatable-interact')
app.layout = html.Div([
html.Div([
html.Button('Update data', id='update-button', n_clicks=0,
style=btn_style),
# dcc.Interval(id='refresh-interval', interval=5000, n_intervals=0),
dcc.Download(id="download"),
html.Br(),
], style=div_style,
),
html.Br(),
html.Div([html.Div([table],
id='body_div', ),
dcc.Loading(
id="loading_item",
type="default",
# type="circle",
parent_style=loading_style
),
],
style=div_style),
])
])
@callback(
[Output('body_div', 'children'),
Output('loading_item', 'parent_style'),
],
Input('update-button', 'n_clicks'),
prevent_initial_call=True, )
def update_data(n_clicks):
if n_clicks is None:
raise PreventUpdate
updated_df = df.copy()
return updated_df.to_dict('records')
Что я делаю не так. Спасибо за помощь
Источник: Stack Overflow на русском