I see… you are using a Plotly Graph Object go.Table rather than a Dash DataTable. I think you can change the header by providing a list of column headings like this: header=dict(values=[‘heading 1’, ‘heading 2’ ‘heading 3’’] (or whatever you want to show in your headings).
If you would like to use a Dash DataTable, here are two examples. The first example will make the column headings in the table the same as the df column headings using: columns=[{"name": i, "id": i} for i in df.columns],
The second example shows a more detailed column definition. This is one way to do things like show only certain columns, or change headings, or add formatting or making them editable etc. You can do a lot with a DataTable - this shows only a few things.
import dash
import dash_table
import dash_html_components as html
import dash_table.FormatTemplate as FormatTemplate
import pandas as pd
df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv"
)
app = dash.Dash(__name__)
app.layout = html.Div(
[
html.H3("Example 1"),
dash_table.DataTable(
id="table",
columns=[{"name": i, "id": i} for i in df.columns],
data=df.to_dict("records"),
style_table={"height": "200px", "overflowY": "auto"},
),
html.H3("Example 2"),
dash_table.DataTable(
id="table2",
columns=[
{"name": "Country", "id": "country"},
{
"name": "Population",
"id": "pop",
"renamable": True,
"type": "numeric",
"format": {"specifier": ",.0f"},
},
{
"name": "Life Expectancy (Yrs)",
"id": "lifeExp",
"renamable": True,
"type": "numeric",
"format": {"specifier": ".1f"},
},
{
"name": "GDP Per Capita",
"id": "gdpPercap",
"renamable": True,
"type": "numeric",
"format": FormatTemplate.money(0),
},
],
data=df.to_dict("records"),
style_table={"height": "200px", "overflowY": "auto"},
),
]
)
if __name__ == "__main__":
app.run_server(debug=True)