Skip to content Skip to sidebar Skip to footer

Python Error : Typeerror: Object Of Type 'timestamp' Is Not Json Serializable'

I have a Dataframe that has a time stamp column of type 'datetime64[ns]'. When I try to insert it to Salesforce platform get an error 'TypeError: Object of type 'Timestamp' is not

Solution 1:

You can try convert datetime to string:

df['Date'] = df['Date'].astype(str)

Or:

df['Date'] = df['Date'].dt.strftime('%Y-%m-%d %H:%M:%S')

print (df.dtypes)
Id      object
Name    object
Date    objectTypeobject
dtype: object

Solution 2:

If you get an error TimeStamp has no attribute as "astype(str)", you can try, for example, str(timeseries.index[0]). This will convert the timestamp into a string that can then be serialized.

Post a Comment for "Python Error : Typeerror: Object Of Type 'timestamp' Is Not Json Serializable'"