Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id action
- date
- 1900-11-01 00:00:00 10.0 starts_game
- 1900-11-01 00:05:00 10.0 team_a_scores
- 1900-11-01 00:25:00 10.0 team_a_scores
- 1900-11-01 00:30:00 10.0 team_a_scores
- 1900-11-01 00:55:00 10.0 team_b_scores
- 1900-11-01 23:58:00 99.0 starts_game
- 1900-11-02 00:40:00 99.0 team_b_scores
- 1900-11-02 00:50:00 99.0 team_b_scores
- 1900-11-03 00:05:00 10.0 starts_game
- 1900-11-03 00:24:00 10.0 team_b_scores
- data.resample('T').ffill().head()
- id action
- date
- 1900-11-01 00:00:00 10.0 starts_game
- 1900-11-01 00:01:00 10.0 starts_game
- 1900-11-01 00:02:00 10.0 starts_game
- 1900-11-01 00:03:00 10.0 starts_game
- 1900-11-01 00:04:00 10.0 starts_game
- data.resample('T').agg(dict(id='ffill', action=lambda _: 'playing')).head()
- id action
- date
- 1900-11-01 00:00:00 10.0 playing
- 1900-11-01 00:01:00 NaN playing
- 1900-11-01 00:02:00 NaN playing
- 1900-11-01 00:03:00 NaN playing
- 1900-11-01 00:04:00 NaN playing
- date,id,action
- 1900-11-01 00:00:00,10.0,starts_game
- 1900-11-01 00:05:00,10.0,team_a_scores
- 1900-11-01 00:25:00,10.0,team_a_scores
- 1900-11-01 00:30:00,10.0,team_a_scores
- 1900-11-01 00:55:00,10.0,team_b_scores
- 1900-11-01 23:58:00,99.0,starts_game
- 1900-11-02 00:40:00,99.0,team_b_scores
- 1900-11-02 00:50:00,99.0,team_b_scores
- 1900-11-03 00:05:00,10.0,starts_game
- 1900-11-03 00:24:00,10.0,team_b_scores
- import pandas as pd
- filename = 'your_custom_name.csv'
- data = pd.read_csv(filename)
- data = data.set_index('date')
Add Comment
Please, Sign In to add comment