question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Object of type 'Timestamp' is not JSON serializable

See original GitHub issue

Trying to make a chart with pandas.Timestamp on the X axis and a floating point value on the Y axis.

alt.Chart(data).mark_line().encode(
    x='timestamp:T',
    y='value:Q'
)

I get the following error:

TypeError: Object of type 'Timestamp' is not JSON serializable

Tried various date/time methods described here but I always get this error.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
jakevdpcommented, Mar 3, 2019

Yeah, altair will serialize the entire dataset that you build a chart with, because it’s difficult to determine from the Python side which columns the renderer will reference.

Glad the problem is fixed!

2reactions
scttnlsncommented, Mar 3, 2019

Ahh, I had some other columns that were of type object and dropping those resolves the error. I was not aware that unused columns would cause an issue like that. Thanks for you help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Object of type 'Timestamp' is not JSON serializable'
If you get an error TimeStamp has no attribute as "astype(str)" , you can try, for example, str(timeseries.index[0]) .
Read more >
TypeError: Object of type Timestamp is not JSON serializable
The Python TypeError: Object of type Timestamp is not JSON serializable occurs when we try to convert a `Timestamp` object to a JSON...
Read more >
Object of Type Datetime Is Not Json Serializable in Python
When we get the object of type datetime is not JSON serializable exception in Python, it means that the datetime object cannot be...
Read more >
TypeError: Object of type Timestamp is not JSON serializable
TypeError : Object of type Timestamp is not JSON serializable - I have tried to fix to no avail, any suggestions or help?...
Read more >
TypeError: Object of type 'Timestamp' is not JSON serializable ...
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...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found