title: Number of samples, -5, must be non-negative using panda python
body: <p>I have a csv file with date and time. I want to give specific timeinterval (60min) in between time range (start time and end time). I wrote a code with a date. But it gives me an error  Number of samples, -5, must be non-negative. Then I checked with separate csv file with less data. Then I found that I have time like 9:53 , 10:20 ,11:42 .... Then when I'm dividing to find num_periods then its give me an error.
   example
  take date range like
  2018 /8/6 start time is 6:00
  2018/8/6 end time is 23:52
  then it between I have time like 7:00, 8:52,10:42 so on. 
  after that in next day I have a time period like this.
  So when I tried to find a num_periods then it give me this error.
  I want to specify time in between this time_range
  (start_time+time_interval(3600 in seconds (60min)) in between time_range)
  Can anyone give me solution for this?
  my code is,</p>
  
  <pre><code>time_interval = 3600 
  date_array = []
  date_array.append(pd.to_datetime(data['date'][0]).date())
  
  start_time = []
  end_time   = []
  
  temp_date  = pd.to_datetime(data['date'][0]).date()
  start_time.append(pd.to_datetime(data['time'][0], format='%H:%M:%S').time())
  
  for i in range(len(data['date'])):
  cur_date = pd.to_datetime(data['date'][i]).date()
  if( cur_date &gt; temp_date):
      end_time.append(pd.to_datetime(data['time'][i-1], format='%H:%M:%S').time())
      start_time.append(pd.to_datetime(data['time'][i], format='%H:%M:%S').time())
      date_array.append(cur_date)
      temp_date = cur_date
  
  end_time.append(pd.to_datetime(data['time'][len(data['date'])-1], format='%H:%M:%S').time())
  datetime_array = []
  for i in range(len(date_array)):
  s_time = datetime.datetime.combine(date_array[i],start_time[i])
  e_time = datetime.datetime.combine(date_array[i],  end_time[i])
  
  timediff = (e_time - s_time)
  num_periods = int(timediff.total_seconds()/time_interval) +1 
  time_list = pd.date_range(start=s_time, end = e_time, periods=num_periods ).to_pydatetime()
  datetime_array.extend(time_list)
  </code></pre>
  
  <p>error:
  <a href="https://i.stack.imgur.com/E097y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E097y.png" alt="enter image description here"></a></p>
  
  <p>subset of my csv file
  <a href="https://i.stack.imgur.com/Ey6ZK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ey6ZK.png" alt="enter image description here"></a></p>