Oh dear… Not very pretty, far too many data points.
Let’s start resampling, we’ll start with a weekly summary.
The resample method in pandas is similar to its groupby method as you are essentially grouping by a certain time span. You then specify a method of how you would like to resample.
So we’ll start with resampling the speed of our car:
df.speed.resample() will be used to resample the speed column of our DataFrame
'W' indicates we want to resample by week. At the bottom of this post is a summary of different time frames.
mean() is used to indicate we want the mean speed during this period.
With distance, we want the sum of the distances over the week to see how far the car travelled over the week, in that case we use
With cumulative distance we just want to take the last value as it’s a running cumulative total, so in that case we use