I have imported a dataframe from an Excel file. The file contains a table of speed and duration in minutes. My ultimate aim is to convert this to a dataframe with even time steps at 1 second intervals. The speed should be repeated for each timestep. This is for import into another tool.
I'm struggling to understand where to start here. The only method I can find that seems like it might work is iterating over each row to calculate the timestamp and appending to a new dataframe. This seems really inefficient.
Can someone give me a steer here?
Sample input is below.
| speed | time | |
|---|---|---|
| 0 | 5 | 0.75 |
| 1 | 6 | 3.12 |
| 2 | 14 | 5.10 |
| 3 | 38 | 19.11 |
| 4 | 7 | 4.32 |
| 5 | 5 | 1.50 |
| 6 | 3 | 11.10 |
| 7 | 3 | 1.50 |
| 8 | 9 | 3.60 |
| 9 | 3 | 19.11 |
| 10 | 38 | 5.10 |
| 11 | 5 | 3.12 |
| 12 | 4 | 0.75 |
Sample output
| timestamp | speed | |
|---|---|---|
| 0 | 00:00:00 | 5 |
| 1 | 00:00:01 | 5 |
| ... | ... | ... |
| 45 | 00:00:45 | 6 |
| 46 | 00:00:46 | 6 |
| 47 | 00:00:47 | 6 |
| .. | .. | .. |