Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Outputting Pandas dataframe as table in Dash breaks for booleans, dicts

I am trying to print a dataframe as a table in Dash. Following the tutorial, I implemented this in a callback function that outputs an HTML component. However, I found that if my dataframe contains booleans (True/False), and sometimes dictionaries, it breaks the table and plot output for the entire app. I don’t see any errors in the console log, the other plots and tables that were previously displaying fine just stop working. Here is an example of the callback function I am using:

    Output(component_id = 'stats-table', component_property = 'children'),
    [Input(component_id = 'selection', component_property = 'value')]
def df_table(input_value):
    max_rows = 10
    df1 = pd.DataFrame([True], index=[0], columns=['A']) # breaks all plot and table output
    df2 = pd.DataFrame([{'id': 'value'}], index=[0], columns=['A']) # cant see row
    df3 = pd.DataFrame([1], index=[0], columns=['A']) # this works fine
    # Header
    [html.Tr([html.Th(col) for col in df1.columns])] +

    # Body
        html.Td(df1.iloc[i][col]) for col in df1.columns
    ]) for i in range(min(len(df1), max_rows))]