Black Lives Matter. Please consider donating to Black Girls Code today.

Header Display that differs from underlying dataframe for DataTable

Finally found a project well suited for Dash, which has been exciting - coming from a Shiny background.

Is it possible to have a display header for a DataTable that is not exactly the same character values as the underlying datatable column? The use case would be to display units that correspond to the values in the particular column, without mucking up the column names in the underlying python code. You could also imagine a pretty print of the column name for enhanced readability.

Example

head(df)
['E111','K']

that I would like to be displayed as:

E111 (GPa) K (GPa)

I could introduce _ to the variable names, but looking for a nicer solution. Obviously, the current header situation is fine for my use case.

Hm, good question. I don’t think this is possible right now. Assigning your own columns property might work but I haven’t tested it. It looks like we’re using the same column names as the column IDs (keys) in the code: https://github.com/plotly/dash-table-experiments/blob/master/src/components/DataTable.react.js#L85-L87. Ideally, we should allow these to be separate.

1 Like