> For the complete documentation index, see [llms.txt](https://shahyaseen71.gitbook.io/technocolabs-data-internship/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shahyaseen71.gitbook.io/technocolabs-data-internship/mini-project/task5.md).

# Task5

### Running statistics <a href="#id-5.-running-statistics" id="id-5.-running-statistics"></a>

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`.

## Helpful links:

* Resampling time series data [exercise](https://campus.datacamp.com/courses/manipulating-time-series-data-in-python/basic-time-series-metrics-resampling?ex=12) from Manipulating Time Series Data in Python
* `resample()` function [documentation](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.resample.html?highlight=resample#pandas.DataFrame.resample)
