SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. time_interval = 14400 #interval in seconds (14400s = 360 minutes)
  2. date_array = []
  3. date_array.append(pd.to_datetime(df1['date'][0]).date())
  4. start_time = []
  5. end_time   = []
  6. temp_date  = pd.to_datetime(df1['date'][0]).date()
  7. start_time.append(pd.to_datetime(df1['time'][0], format='%H:%M:%S').time())
  8. for i in range(len(df1['date'])):
  9. cur_date = pd.to_datetime(df1['date'][i]).date()
  10. if( cur_date > temp_date):
  11.     end_time.append(pd.to_datetime(df1['time'][i-1], format='%H:%M:%S').time())
  12.     start_time.append(pd.to_datetime(df1['time'][i], format='%H:%M:%S').time())
  13.     date_array.append(cur_date)
  14.     temp_date = cur_date
  15.     end_time.append(pd.to_datetime(df1['time'][len(df1['date'])-1], format='%H:%M:%S').time())
  16.   datetime_array = []
  17.   for i in range(len(date_array)):
  18. s_time = datetime.datetime.combine(date_array[i],start_time[i])
  19. e_time = datetime.datetime.combine(date_array[i],  end_time[i])
  20.  
  21. timediff = (e_time - s_time)
  22. #num_periods = int(timediff.total_seconds()/t3ime_interval) +1
  23. num_periods = abs(int(timediff.total_seconds()/time_interval)) + 1
  24. time_list = pd.date_range(start=s_time, end = e_time, periods=num_periods ).to_pydatetime()
  25. datetime_array.extend(time_list)
  26. time_stamps = [datetime.datetime.strftime(t,'%H:%m:%S') for t in datetime_array]
  27. x = np.zeros([num_periods], dtype='timedelta64[s]')
  28. plt.xticks(np.arange(num_periods), time_stamps)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top