Px.timeline converts x-axis to unusable timedelta type

Even if I just copy and paste the example code from the timeline page, I get:

TypeError: Object of type timedelta is not JSON serializable.

Example code:

import plotly.express as px
import pandas as pd

df = pd.DataFrame([
    dict(Task="Job A", Start='2009-01-01', Finish='2009-02-28'),
    dict(Task="Job B", Start='2009-03-05', Finish='2009-04-15'),
    dict(Task="Job C", Start='2009-02-20', Finish='2009-05-30')

fig = px.timeline(df, x_start="Start", x_end="Finish", y="Task")
fig.update_yaxes(autorange="reversed") # otherwise tasks are listed from the bottom up

From my investigation, I’ve found that plotly seems to be setting the x-axis to a timedelta object. I’m currently running the most recent version of plotly and pandas.

1 Like

I’ve encountered the same problem