I am using Dash DataTable and have datetime64 types in columns that have been read from a JSON object that was stored in a Store component.
The column’s that are datetime64 are displayed as followed:
1975-11-08T00:00:00
Is there a way to display the date with no time data without changing the dtype to object?
I have tried this:
mainData = pd.read_json(data, orient='table')
for cols in mainData.columns:
print(mainData[cols].dtype)
if mainData[cols].dtype == 'datetime64[ns]':
mainData[cols] = pd.to_datetime(mainData[cols]).dt.normalize()
# This changes the type to object which is not ideal.
# mainData[cols] = pd.to_datetime(mainData[cols])
# mainData[cols] = mainData[cols].dt.date
print(mainData[cols].dtype)
print(mainData.dtypes)
If I print out the column no time data is printed out only when displayed in DashTable:
datetime64[ns]
0 1975-11-08
1 1974-08-30
2 1978-10-15
3 1980-04-05
4 1975-03-12