Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement