Addb
1
Hello,
I can’t make plots on streamlit using the px.timeline, even using the basic dummy data this is always returning
TypeError: Object of type timedelta is not JSON serializable
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
st.plotly_chart(fig)
Skiks
2
Hi @Addb !
Welcome on the forum!
Nothing is wrong with px.timeline()
I’ve never used streamlit, but using this snippet locally, I get:
I used it a couple of weeks ago to help someone:
I would say that’s coming from streamlit.
Try print(fig)
before st.plotly_chart(fig)
to see what px.timeline()
outputs.
1 Like
Interesting. I’ve had the same error, in my post here:
But running that snippet now in my console, I get no error.
Skiks
4
Programming can be a mystery sometime !
But I prefer a working mystery than a not working mystery !
1 Like