Skip to content Skip to sidebar Skip to footer

Python Pandas Read_excel And To_json Date Format Error

Below is the data from an excel which I am trying to convert to JSON using pandas read_excel and to_json functions. The JSON date has the field 'Date' as 1449446400000 (without quo

Solution 1:

You have to set the date_format when writing to json with:

json = df.to_json(orient="records", date_format='iso')

Since the default is 'epoch', without setting it explicity to 'iso', you're getting your results in epoch milliseconds. This returns for a sample output:

'[{"id":5,"date":"2015-07-12T00:00:00.000Z"}]'

Post a Comment for "Python Pandas Read_excel And To_json Date Format Error"