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!

BUG: in tables - boolean values fail to render

When I try to output raw values like True/False I get a strange error saying ‘Error loading dependencies’.

The solution is very simple encode the values to string but the error should be improved as I had to guess what was causing it.
Please see the code needed to replicate error:

Try this:
def load_data():
return pd.DataFrame({“A” : [1,2,3,4], “B” : [True,False,True,False]})

def generate_table(dataframe, max_rows=10):
return html.Table(
    # Header
    [html.Tr([html.Th(col) for col in dataframe.columns])] +

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

app = dash.Dash()

app.layout = html.Div(children=[
html.H4(children='US Agriculture Exports (2011)'),
generate_table(load_data())
])

if __name__ == '__main__':
app.run_server(debug=True,port=777)
1 Like

Thanks for reporting! Tracking in https://github.com/plotly/dash-renderer/issues/29

Of course, for now, you can just stringify the data before you want to plot it, i.e. str(dataframe.iloc[i][col])