Hello,
Currently I have a pandas dataframe :
df = pd.DataFrame({
"date": ["20210613", "20210614", "20210615"],
"user": ["A\nB", "C", "D"],
"machine" : [1, 0, 3]
})

I wonder if there is any way to print a table like this:

no matter using dcc.Textarea or dash_table.DataTable is OK.
Currently I still can not figure out a good way to achieve this, many thanks.
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)

1 Like