I would like to write a (pandas) DataFrame to a json file. But one of my columns is a date and when I read from the json file the date format is Miliseconds(?)
from pandas import DataFrame, read_json
from datetime import date
A = {'a': [date(2019,1,1),date(2019,1,2),date(2019,1,2)], 'b': [4,5,6]}
df = DataFrame(A)
print(df)
filename = r'C:\temp\Export_DataFrame.json'
#to json file
Export = df.to_json(filename)
#import from json
df2 = read_json(filename)
print(df2)
gives me the following result:
a b
0 2019-01-01 4
1 2019-01-02 5
2 2019-01-02 6
a b
0 1546300800000 4
1 1546387200000 5
2 1546387200000 6
When reading the json file how do I convert to datetime?
Thx in advance