Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import pandas as pd
  2. index = pd.date_range('2013-1-1',periods=10,freq='15Min')
  3. data = pd.DataFrame(data=[1,2,3,4,5,6,7,8,9,0], columns=['value'], index=index)
  4.  
  5. data['value'] > 3
  6. Out[40]:
  7. 2013-01-01 00:00:00 False
  8. 2013-01-01 00:15:00 False
  9. 2013-01-01 00:30:00 False
  10. 2013-01-01 00:45:00 True
  11. 2013-01-01 01:00:00 True
  12. 2013-01-01 01:15:00 True
  13. 2013-01-01 01:30:00 True
  14. 2013-01-01 01:45:00 True
  15. 2013-01-01 02:00:00 True
  16. 2013-01-01 02:15:00 False
  17. Freq: 15T, Name: value, dtype: bool
  18.  
  19. In [11]: data.index.indexer_between_time(start='01:15', end='02:00')
  20. Out[11]: array([5, 6, 7, 8])
  21.  
  22. In [12]: data.iloc[data.index.indexer_between_time(start='1:15', end='02:00')]
  23. Out[12]:
  24. value
  25. 2013-01-01 01:15:00 6
  26. 2013-01-01 01:30:00 7
  27. 2013-01-01 01:45:00 8
  28. 2013-01-01 02:00:00 9
  29.  
  30. data.iloc[data.index.indexer_between_time('1:15', '02:00')]
  31. Out[90]:
  32. value
  33. 2013-01-01 01:15:00 6
  34. 2013-01-01 01:30:00 7
  35. 2013-01-01 01:45:00 8
  36. 2013-01-01 02:00:00 9
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement