I’m outputting a dataframe to the layout in my app using dash_table.DataTable
.
The relevant column displays as:
2021-01-01T02:00:00
I want to replace the ‘T’ with a space - I think the T is confusing for a non-technical user.
I tried this argument in my DataTable definition but it didn’t do anything:
columns=[{'name': 'Timestamp', 'id': 'ds', 'type': 'datetime', 'format': dict(specifier='%Y-%m-%d %H:%M:%S')}
],
What is the most elegant solution here?
Hi @matsuobasho
Why don’t you make the change in the dataframe itself? you can do something like this:
df['datetime'] = pd.to_datetime(df['datetime'].str.replace('T', ' '))
Because this ‘T’ is a dash.DataTable
display feature. It is not part of pandas the datetime datatype. The datetime type output in Pandas looks normal, without the ‘T’
Hello @matsuobasho,
I don’t know if this is possible with DataTable.
But it definitely available with AG Grid. You can pass a custom valueFormatter
which can display the data in any way that you want.