I'm trying to remove the weekend gaps from this time series plot. The x-axis is a data time stamp. I've tried the code on this site, but can't get it to work. See sample file used
The data looks like this
+-----------------------+---------------------+-------------+-------------+
| asof | INSERTED_TIME | DATA_SOURCE | PRICE |
+-----------------------+---------------------+-------------+-------------+
| 2020-06-17 00:00:00 | 2020-06-17 12:00:15 | DB | 170.4261757 |
+-----------------------+---------------------+-------------+-------------+
| 2020-06-17 00:00:00 | 2020-06-17 12:06:10 | DB | 168.9348656 |
+-----------------------+---------------------+-------------+-------------+
| 2020-06-17 00:00:00 | 2020-06-17 12:06:29 | DB | 168.8412129 |
+-----------------------+---------------------+-------------+-------------+
| 2020-06-17 00:00:00 | 2020-06-17 12:07:27 | DB | 169.878796 |
+-----------------------+---------------------+-------------+-------------+
| 2020-06-17 00:00:00 | 2020-06-17 12:10:28 | DB | 169.3685879 |
+-----------------------+---------------------+-------------+-------------+
| 2020-06-17 00:00:00 | 2020-06-17 12:12:14 | DB | 169.0787045 |
+-----------------------+---------------------+-------------+-------------+
| 2020-06-17 00:00:00 | 2020-06-17 12:12:33 | DB | 169.7561092 |
+-----------------------+---------------------+-------------+-------------+
Plot including weekend breaks
Using the line function I'm getting the plot below, with straight lines going from Friday end of day to Monday morning. Using px.scatter, I don't get the line, but I still get the gap.
import plotly.express as px
import pandas as pd
sampledf = pd.read_excel('sample.xlsx')
fig_sample = px.line(sampledf, x = 'INSERTED_TIME', y= 'PRICE', color = 'DATA_SOURCE')
fig_sample.show()
Attempt with no weekend breaks
fig_sample = px.line(sampledf, x = 'INSERTED_TIME', y= 'PRICE', color = 'DATA_SOURCE')
fig_sample.update_xaxes(
rangebreaks=[
dict(bounds=["sat", "mon"]) #hide weekends
]
)
fig_sample.show()
Using rangebreaks results in a blank plot.
Any help is appreciated. Thanks