@mike0whit
I converted df[‘start’] and df[‘end’] , via pd.to_datetime()
and here is what I got:
import plotly.express as px
import pandas as pd
d = [{'instance': 'i-123', 'start': '2020-08-15T17:28:19+00:00', 'end': '2020-08-15T17:33:01+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T15:43:56+00:00', 'end': '2020-08-14T15:43:58+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T16:40:26+00:00', 'end': '2020-08-14T17:34:42+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T15:29:49+00:00', 'end': '2020-08-14T15:29:50+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T16:38:57+00:00', 'end': '2020-08-14T16:40:24+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T15:30:00+00:00', 'end': '2020-08-14T15:30:01+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T15:29:56+00:00', 'end': '2020-08-14T15:29:57+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T17:34:46+00:00', 'end': '2020-08-14T18:42:31+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T15:29:58+00:00', 'end': '2020-08-14T15:29:59+00:00'},
{'instance': 'i-123', 'start': '2020-08-17T21:10:55+00:00', 'end': '2020-08-17T21:13:28+00:00'},
{'instance': 'i-123', 'start': '2020-08-14T14:55:53+00:00', 'end': '2020-08-14T15:50:45+00:00'},
{'instance': 'i-123', 'start': '2020-08-17T19:52:10+00:00', 'end': '2020-08-17T19:54:42+00:00'},
{'instance': 'i-123', 'start': '2020-08-17T19:15:34+00:00', 'end': '2020-08-17T19:18:06+00:00'}]
df = pd.DataFrame(d)
for col in ['start', 'end']:
df[col] = pd.to_datetime(df[col])
df['id'] = [idx for idx in df.index]
print(df['start'].min(), df['end'].max())
fig = px.timeline(df, x_start="start", x_end="end", y="id")
fig.update_xaxes(range=[df['start'].min(), df['end'].max()]) #THIS IS A NECESSARY UPDATE!!!!
fig.update_traces(width=0.15)
fig.show()
Data from the last two rows of the dataframe are not displayed. This is the time difference:
df['end'] - df['start']
0 00:04:42
1 00:00:02
2 00:54:16
3 00:00:01
4 00:01:27
5 00:00:01
6 00:00:01
7 01:07:45
8 00:00:01
9 00:02:33
10 00:54:52
11 00:02:32
12 00:02:32
dtype: timedelta64[ns]