SHARE
TWEET

Untitled

a guest Jun 18th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from time import time
  2. import pandas as pd
  3. import numpy as np
  4.  
  5. periods = 40 * 365 * 24
  6. tidx = pd.date_range("2016-07-01", periods=periods, freq="H")
  7.  
  8. np.random.seed(0)
  9. data = np.random.randn(periods)
  10.  
  11. ts = pd.Series(data=data, index=tidx, name="HelloTimeSeries")
  12.  
  13. b = time()
  14.  
  15. x = ts.array.to_numpy()
  16. n = x.shape[0]
  17. d = dict()
  18.  
  19. for i in range(0, n, 24):
  20.     d[ts.index[i].date()] = x[max(24 * (i - 15), 0) : min(24 * (i + 15), n)]
  21.  
  22. e = time()
  23. print(e - b)
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