Dash print dataframe with multiple line in one cell

Hi @JimChen

You can do that using markdown. See more info here


import dash
import dash_table
import pandas as pd

df = pd.DataFrame({
    "date": ["20210613", "20210614", "20210615"],
    "user": ["A \\\n B", "C", "D"],
    "machine" : [1, 0, 3]
})

app = dash.Dash(__name__)

app.layout = dash_table.DataTable(
    id='table',
    columns=[{"name": i, "id": i, "presentation": "markdown"} for i in df.columns],
    data=df.to_dict('records'),
)

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


image

1 Like