0

I have a pandas dataframe with the following DatetimeIndex:

DatetimeIndex(['2019-06-13 15:30:00', '2019-06-13 15:31:00',
               '2019-06-13 15:32:00', '2019-06-13 15:33:00',
               ....
               '2020-03-06 21:56:00', '2020-03-06 21:57:00',
               '2020-03-06 21:58:00', '2020-03-06 21:59:00'],
              dtype='datetime64[ns]', name='Date', length=72622, freq=None)

The 'Time' starts 15:30 and ends 21:59 in 1 minute intervals.
I'm plotting now a column with numbers but the problem is that there are gaps in between the times 22:00 - 15:29

enter image description here

Any suggestions to make it a continuous data point series?

UPDATE:
This is the code I'm using:

import pandas as pd
import numpy as np
sp = pd.read_csv('ES_M1_askbid_1yr.csv')
sp.columns = sp.columns.str.strip()
sp.rename(columns = {'Close' : 'Delta'}, inplace=True)
sp['Date'] = pd.to_datetime(sp['Date'] + ' ' + sp['Time'])
sp.set_index('Date', inplace=True)
sp.drop(['Time','K', 'L', 'M', 'N', 'Bid Volume', 'Ask Volume','Open.1'], axis=1, inplace=True)
rangeHLsub = (sp['Low'] - sp['High'])/0.25
rangeOCsub = (sp['Open'] - sp['Last'])/0.25
divBAR_DELTAraw = round((rangeOCsub / sp['Delta'])*100)
sp['div_Bar_Delta_raw'] = divBAR_DELTAraw
sp['div_Bar_Delta'] = sp['div_Bar_Delta_raw'].replace([np.inf, -np.inf], np.nan)
sp.drop(['div_Bar_Delta_raw'], axis=1, inplace=True)
iplot(sp['div_Bar_Delta'].iplot(asFigure=True,
                              kind='scatter',xTitle='Dates',yTitle='div bar delta',title='div bar delta'))
Mark T
  • 145
  • 4
  • 12
  • If you only have data between 15:30 to 21:59, then you could try removing the rows with times between 22:00 to 15:29. That could be one way to eliminate gaps in the series and plot. – Sajan Mar 09 '20 at 11:07
  • There's no data between 22:00 - 15:29. I was thinking the problem could be somewhere in a standard 24 hour formatting – Mark T Mar 09 '20 at 14:01
  • Try checking if you missed getting the data for this time range : 22:00 - 15:29. – Sajan Mar 09 '20 at 14:19
  • I'm not sure if I understand you correctly. I skipped the data between 22:00 and 15:29 intentionally. It's not existent in the csv file – Mark T Mar 09 '20 at 14:24

1 Answers1

0

You could try something like this to remove rows which have no values and only have rows where times are between 15:30 and 21:59 -

import time
df[(df['datetime'].dt.time >= time(15,30)) & (df['datetime'].dt.time <= time(21, 59))]
Sajan
  • 1,247
  • 1
  • 5
  • 13
  • It gives me an error: `unexpected EOF while parsing` – Mark T Mar 09 '20 at 15:34
  • Not sure why that should happen. Do you want to share your code ? Also, take a look at this link - https://stackoverflow.com/questions/43189302/syntaxerror-unexpected-eof-while-parsing – Sajan Mar 09 '20 at 17:46