✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Dash DataTable - Generate new table via callbacks

I’m looking to take an editable input DataFrame, use it as input to a @callback function that generates a new DataFrame (via groupby), display the second DataFrame, and plot some bar graphs from the second DataFrame. Does anyone have any good examples of this? I keep running into the “Error loading dependencies”, which I presume is a euphemism for novice user error.

I think a partial solution is adding an empty rows object in the generated DataFrame, as suggested by HansG in the other post: Display tables in Dash

e.g. rows=[{}],

I just posted an example of a table generated by a callback here: Dash DataTable - Updating the Number of Rows

Did you ever find a solution of how to take an editable input DataFrame, use it as input to a @callback function that generates a new DataFrame (via groupby), display the second DataFrame?

I think I pieced something together from the various examples in the forum. However, my code is currently defunct because it uses the old Tabs functionality and I need to port to the new version of Tabs.

How did you get it to work? What i am looking to do by clicking a button:

  1. Send a datatable’s rows to a new pandas dataframe, then
  2. Run some analytics on that pandas dataframe by calling a function, returning a new pandas dataframe (results_df), then
  3. Create a new datatable from results_df from step 2.

After uploading raw data and creating the input datatable below, how do i do steps 1-3 above? Any guidance would be much appreciated.

dt.DataTable(        id='input datatable',
                            rows=model_input_df.to_dict('records'),
                            row_selectable=True,
                            filterable=True,
                            sortable=True,
                            )
1 Like

Did anyone ever find a solution for this?

1 Like

Hi guys,

I’m currently trying to do this as well. I have a callback that currently generates a DataTable, and I need to allow a user to select one row, click some button (or the row itself, doesn’t matter), and for that to generate a new DataTable.
For additional context, the row would get converted to a dataframe used to generate a SQL query, and that would then pull a fresh set of data to feed into the new table.

Any help would be appreciated!