Display dataframe with groupby in DashTable

So, I have a dataframe that displays correctly in my Notebook but not in a *.py dash app when the datafram is loaded into a DashTable. It appears that the “Grouped By” column is not displaying in the DashTable.

Has anyone run ito this?

Here’s how it looks in my notebook:

Here’s how the DataTable looks:

Here’s how the dataframe is created:

df3 = df.groupby(‘Game_SK’).agg(np.sum)
df3[“Goal_Diff”] = (df3[“Goals”] - df3[“Goals Allowed”])
conditions = [df3[‘Goal_Diff’] > 0, df3[‘Goal_Diff’] == 0, df3[‘Goal_Diff’] < 0]
choices = [‘Win’, ‘Tie’, ‘Loss’]
df3[‘Result’] = np.select(conditions, choices)

Here’s how it’s passed to the DataFrame:

        dash_table.DataTable
            (
            id = 'datatable2',
            columns = [{"name": i, "id": i} for i in df3.columns],
            data=df3.to_dict('records'),
            filter_action='native',
            sort_action='native',
            page_size=20,
            )

What am I missing? Sometype of Index property?

Thank you in advance for your insight.

Joe P.

The easiest way to display it would be to call reset_index(drop=True) on the data frame after your group by.

1 Like

On top of what @Croll12 said, you can highlight your groupby column by using conditional formatting to change the fontWeight to bold (for example).

Thanx team. I got it working now. Great advice.