Guest User

Untitled

a guest
Dec 13th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. id action
  2. date
  3. 1900-11-01 00:00:00 10.0 starts_game
  4. 1900-11-01 00:05:00 10.0 team_a_scores
  5. 1900-11-01 00:25:00 10.0 team_a_scores
  6. 1900-11-01 00:30:00 10.0 team_a_scores
  7. 1900-11-01 00:55:00 10.0 team_b_scores
  8. 1900-11-01 23:58:00 99.0 starts_game
  9. 1900-11-02 00:40:00 99.0 team_b_scores
  10. 1900-11-02 00:50:00 99.0 team_b_scores
  11. 1900-11-03 00:05:00 10.0 starts_game
  12. 1900-11-03 00:24:00 10.0 team_b_scores
  13.  
  14. data.resample('T').ffill().head()
  15.  
  16. id action
  17. date
  18. 1900-11-01 00:00:00 10.0 starts_game
  19. 1900-11-01 00:01:00 10.0 starts_game
  20. 1900-11-01 00:02:00 10.0 starts_game
  21. 1900-11-01 00:03:00 10.0 starts_game
  22. 1900-11-01 00:04:00 10.0 starts_game
  23.  
  24. data.resample('T').agg(dict(id='ffill', action=lambda _: 'playing')).head()
  25.  
  26.  
  27.  
  28. id action
  29. date
  30. 1900-11-01 00:00:00 10.0 playing
  31. 1900-11-01 00:01:00 NaN playing
  32. 1900-11-01 00:02:00 NaN playing
  33. 1900-11-01 00:03:00 NaN playing
  34. 1900-11-01 00:04:00 NaN playing
  35.  
  36. date,id,action
  37. 1900-11-01 00:00:00,10.0,starts_game
  38. 1900-11-01 00:05:00,10.0,team_a_scores
  39. 1900-11-01 00:25:00,10.0,team_a_scores
  40. 1900-11-01 00:30:00,10.0,team_a_scores
  41. 1900-11-01 00:55:00,10.0,team_b_scores
  42. 1900-11-01 23:58:00,99.0,starts_game
  43. 1900-11-02 00:40:00,99.0,team_b_scores
  44. 1900-11-02 00:50:00,99.0,team_b_scores
  45. 1900-11-03 00:05:00,10.0,starts_game
  46. 1900-11-03 00:24:00,10.0,team_b_scores
  47.  
  48. import pandas as pd
  49.  
  50.  
  51. filename = 'your_custom_name.csv'
  52. data = pd.read_csv(filename)
  53.  
  54. data = data.set_index('date')
Add Comment
Please, Sign In to add comment