Task5

Running statistics

No doubt, running helps people stay mentally and physically healthy and productive at any age. And it is great fun! When runners talk to each other about their hobby, we not only discuss our results, but we also discuss different training strategies.

You'll know you're with a group of runners if you commonly hear questions like:

  • What is your average distance?

  • How fast do you run?

  • Do you measure your heart rate?

  • How often do you train?

Let's find the answers to these questions in my data. If you look back at plots in Task 4, you can see the answer to, Do you measure your heart rate? Before 2015: no. To look at the averages, let's only use the data from 2015 through 2018.

In pandas, the resample() method is similar to the groupby() method - with resample() you group by a specific time span. We'll use resample() to group the time series data by a sampling period and apply several methods to each sampling period. In our case, we'll resample annually and weekly.

Calculate annual and weekly means for Distance (km), Average Speed (km/h), Climb (m) and Average Heart Rate (bpm).

  • Subset df_run for data from 2015 through 2018. Assign the result to runs_subset_2015_2018.

  • Count the annual averages using resample() with 'A' alias, and the mean() method for runs_subset_2015_2018.

  • Count the average weekly statistics using resample() with 'W' alias, and the mean() method twice.

  • Filter from dataset column Distance (km) and count the average number of trainings per week using resample() with the count() and mean() methods. Assign the result to weekly_counts_average.

  • Resampling time series data exercise from Manipulating Time Series Data in Python

  • resample() function documentation

Last updated