Dash datatable with list as input in dash version 2.4?

Is there a way to input a list into a newer dash version? I have seen some older examples online e.g. here If I try it- I keep on getting an Invalid error argument [...]- Expected one of type [string, number, boolean]. I am using the latest dash version 2.4.1

Using the example mentioned in the post above- I get the error

import dash
import dash_bootstrap_components as dbc
import pandas as pd

brand_name = ['merc', 'bmw']
driver = [['driver1', 'driver2'], ['driver3', 'driver14']]

df = pd.DataFrame({'brand_name': brand_name, 'driver': driver})
print(df)

df_dict = df.to_dict('records')


app = dash.Dash(__name__)
app.layout = dbc.Card(
    dbc.CardBody(
        [
            dash.dash_table.DataTable(
                id='homepage-table',
                data=df_dict,
                columns=[
                    {'name': 'brand_name', 'id': 'brand_name'},
                    {'name': 'driver', 'id': 'driver', 'presentation': 'markdown'}
                ],
            )]))


if __name__ == '__main__':
    app.run_server(debug=True, port=8080)

hi, did you ever find a solution to this?

1 Like