Hi,
I’m trying to format my table columns so that they are written with units in the cells. I have made an example from the quickstart example in the tutorial, only that I’ve made a new csv file where e.g. 100 MW is stored as 100000000 to let the data_table format option take care of the SI-prefix. As far as I understand the documentation, I should be able to add a W at the end by adding "locale": {"symbol": ["", "W"]}
to the "format"
dict, but it doesn’t seem to work. See code below. Also, when adding SI-prefix to the number formatting, I would like to be able to have a space before the e.g. M for 1e6, but I haven’t found a way to do that? (as a number with SI-units should be written e.g. 1 MW and not 1MW).
import dash
import dash_table
import pandas as pd
df = pd.read_csv("./solar_plant_data.csv")
app = dash.Dash(__name__)
app.layout = dash_table.DataTable(
id='table',
columns=[{"name": i, "id": i, "type": "numeric", "format": {'locale': {'symbol': ['', 'W']}, 'specifier': '.3s'}} for i in df.columns],
data=df.to_dict('records'),
)
if __name__ == '__main__':
app.run_server(debug=True)