Hi, I’m trying to simply output a dataframe to a dash_table from a callback function. If anyone can point me to an example of this I would appreciate it. I’ve looked through a lot of examples on the forum already but they solve the problem for “dash_table_experiments” which is different. Here is an example I cribbed from one of those topis which is not working.
Code:
import dash
from dash.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc
import dash_table
import pandas as pd
app = dash.Dash()
df = pd.DataFrame({‘x’: [‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’],‘y’: [4, 3, 1, 2, 3, 6],‘z’: [‘z’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’]})
app.layout = html.Div([
dash_table.DataTable(
id=‘table’,
columns=[{}],
data={}
),
])
@app.callback(Output(‘table’, ‘data’))
def update_info_table():
columns=[{“name”: i, “id”: i} for i in df.columns]
data=df.to_dict(“rows”)
return columns,data
if name == ‘main’:
app.run_server()
Error:
TypeError: Unexpected keyword argument rows