I have a basic pandas dataframe in python, that takes in data and plots a line graph. Each data point involves a time. If everything runs well with the data file, ideally each time stamp is roughly 30 min different from each other. In some cases, no data comes through for more than in hour. During these times, I want to mark this timeframe as 'missing' and plot a discontinuous line graph, blatantly showing where data has been missing.
I'm having a difficult time figuring out how to do this and even search for a solution as the problem is pretty specific. The data is 'live' where it is constantly updated so I can't just pinpoint a certain area and edit as a workaround.
Something that looks like this:
Code used to create datetime column:
#convert first time columns into one datetime column
df['datetime'] = pd.to_datetime(df[['year', 'month', 'day', 'hour', 'minute', 'second']])
I have figured out how to calculate the time difference, which involved creating a new column. Here is that code just in case:
df['timediff'] = (df['datetime']-df['datetime'].shift().fillna(pd.to_datetime("00:00:00", format="%H:%M:%S")))
Basic look at dataframe:
datetime l1 l2 l3
2019-02-03 01:52:16 0.1 0.2 0.4
2019-02-03 02:29:26 0.1 0.3 0.6
2019-02-03 02:48:03 0.1 0.3 0.6
2019-02-03 04:48:52 0.3 0.8 1.4
2019-02-03 05:25:59 0.4 1.1 1.7
2019-02-03 05:44:34 0.4 1.3 2.2
I'm just not sure how to go about creating a discontinuous 'live' plot involving the time difference.
Thanks in advance.