Hi, I am new to python and plotly. I am trying to use plotly.express timeline to draw process event durations.
A simple test like the following python code allows me to draw my basic requirement:
============
import plotly.express as px
import pandas as pd
df = pd.DataFrame([
dict(Task=βWk1β, Start=β2.1β, End=β5.5β, Category=βGroup1β),
dict(Task=βWk2β, Start=β5.5β, End=β10.0β, Category=βGroup1β),
dict(Task=βWk3β, Start=β22.3β, End=β28.9β, Category=βGroup1β),
dict(Task=βWk4β, Start=β12.6β, End=β14.0β, Category=βGroup2β),
dict(Task=βWk5β, Start=β14.0β, End=β18.3β, Category=βGroup2β),
dict(Task=βWk6β, Start=β18.3β, End=β20.8β, Category=βGroup2β)
])
df[βStartβ] = pd.to_datetime(df[βStartβ], unit=βsβ)
df[βEndβ] = pd.to_datetime(df[βEndβ], unit=βsβ)
fig = px.timeline(df, x_start=βStartβ, x_end=βEndβ, y=βCategoryβ, color=βTaskβ)
fig.show()
============
where each work start time and end time are logged in microseconds (us). However, if I change the pd.to_datetime unit to βusβ, only a blank graph will show, without any process bar showing.
It looks like in pd.DataFrame, the datetime type is datetime64[ns], which I assume can be accurate to βnsβ. How can I show a timeline bar in βusβ in plotly graph?
Thanks for help!