Dash DataTable - Formatter string

is there a way to define a formatter string for displaying numbers in the DataTable component?

1 Like

you can format data in pandas dataframe and DataTable will display them that way as they are. i use:
to display percent value. and
to display float type without decimal part.


Thanks @roman, this is useful. However, when I format numbers this way, the Dash data table no longer sorts correctly. Here’s an example:

The comma is regarded as a character used in the sorting, so 98,087,500 falls between 990,000,000 and 977,000,000

Do you have any ideas how to solve this? I tried also changing the display format of the underlying dataframe, but this formatting was not reflected in the Dash data table.

pd.options.display.float_format = '{:,.0f}'.format

1 Like

HI! Same problem. I just switch off sorting for the table whith formatting =( As i can understand problem starts after .map or .format float type becouse it converts float to string and we get unexpected result of sorting. To solve this, i think we can create some component mb dcc.dropdown with column names and sort pandas dataframe and format it and after display at table in callback of that dropdown.

Also tracking in Adding comma number formatting or get filtering to work with comma separated strings · Issue #17 · plotly/dash-table-experiments · GitHub

I don’t believe that there is a workaround for this issue yet besides doing server-side sorting/filtering with callbacks as mentioned here:

Was this ever solved in the DataTable component? Thanks!

Yes, scroll down to Examples in here: Typing and User Input Processing | Dash for Python Documentation | Plotly

Same problem. Even after rounding data I get something like 2.8333333333