I would like to read a .csv file and return a groupby function as a callback to be displayed as a simple data table with \"dash_table\" library. @Lawliet\'s helpful answer shows
You almost got it done just with minor modification in update_datatable
it should work fine (not tested):
def update_datatable(n_clicks,csv_file):
if n_clicks:
dfgb = df.groupby(['state']).sum()
return html.Div([dash_table.DataTable(
data=dfgb.to_dict('rows'),
columns=[{'name': i, 'id': i} for i in dfgb.columns],
style_header={'backgroundColor': "#FFD700",
'fontWeight': 'bold',
'textAlign': 'center',},
style_table={'overflowX': 'scroll'},
style_cell={'minWidth': '180px', 'width': '180px',
'maxWidth': '180px','whiteSpace': 'normal'},
filtering=True,
row_selectable="multi",
n_fixed_rows=1),
html.Hr()
])