<commit_before># activityio: Exercise data handling library
____

Exercise/activity data has become a prolific resource, but applying any kind of sophisticated analyses is made difficult by the variety of file formats. This `python` library is intended to munge a number of these formats and present the data in a predictable and useable form. Moreover, the API is both closely intertwined with, and an extension of, the awesome [`pandas`](https://github.com/pandas-dev/pandas) library.

## Installation

The package is available on PyPI:

```
pip install activityio
```

## Example usage

There is a `read` function at the top-level of `activityio` that dispatches the appropriate reader based on file extension:

```python
>>> import activityio as aio
>>> data = aio.read('example.srm')
```

But you can also use sub-packages explicitly:

```python
>>> from activityio import srm
>>> data = srm.read('example.srm')
```

`data` is a subclass of the `pandas.DataFrame` and provides some neat additional functionality. Most notably, certain columns are "magic" in that they return specific `pandas.Series` subclasses. These subclasses make unit-switching easy, and provide other useful methods.

```python
>>> type(data)
<class 'activityio._util.types.ActivityData'>

>>> data.head(5)
          lap    dist  pwr   speed  temp  alt  cad  hr
time                                                  
00:00:00    1   5.611    0   5.611  26.8  530    0   0
00:00:01    1  10.999    0   5.388  26.8  530    0   0
00:00:02    1  25.054    0  14.055  27.1  532    0   0
00:00:03    1  42.609    0  17.555  27.1  532    0   0
00:00:04    1  59.414    0  16.805  27.3  532    0   0

>>> data.normpwr()
279.40584154170227

>>> type(data.speed)
<class 'activityio._util.types.Speed'>
>>> data.speed.base_unit
'm/s'
>>> data.speed.kph.mean()  # use a different unit
41.045473986415516

>>> data.dist.base_unit
'm'
>>> data.dist.miles[-1]
101.17480453266764

>>> data.alt.base_unit
'm'
>>> data.alt.ascent.sum()
1779.0
```

But note that you lose this functionality if you go changing column names:

```python
>>> data = data.rename(columns={'alt': 'altitude'})
>>> type(data.altitude)
<class 'pandas.core.series.Series'>
```

## API Notes

The main package is composed of sub-packages that contain the reading logic for the file format after which they're named. (e.g. `activityio.fit` is for parsing ANT/Garmin FIT files.) 
<commit_msg>Use proper python console syntax highlighting.<commit_after># activityio: Exercise data handling library

Exercise/activity data has become a prolific resource, but applying any kind of sophisticated analyses is made difficult by the variety of file formats. This `python` library is intended to munge a number of these formats and present the data in a predictable and useable form. Moreover, the API is both closely intertwined with, and an extension of, the awesome [`pandas`](https://github.com/pandas-dev/pandas) library.

## Installation

The package is available on PyPI:

```
pip install activityio
```

## Example usage

There is a `read` function at the top-level of `activityio` that dispatches the appropriate reader based on file extension:

```pycon
>>> import activityio as aio
>>> data = aio.read('example.srm')
```

But you can also use sub-packages explicitly:

```pycon
>>> from activityio import srm
>>> data = srm.read('example.srm')
```

`data` is a subclass of the `pandas.DataFrame` and provides some neat additional functionality. Most notably, certain columns are "magic" in that they return specific `pandas.Series` subclasses. These subclasses make unit-switching easy, and provide other useful methods.

```pycon
>>> type(data)
<class 'activityio._util.types.ActivityData'>

>>> data.head(5)
          lap    dist  pwr   speed  temp  alt  cad  hr
time                                                  
00:00:00    1   5.611    0   5.611  26.8  530    0   0
00:00:01    1  10.999    0   5.388  26.8  530    0   0
00:00:02    1  25.054    0  14.055  27.1  532    0   0
00:00:03    1  42.609    0  17.555  27.1  532    0   0
00:00:04    1  59.414    0  16.805  27.3  532    0   0

>>> data.normpwr()
279.40584154170227

>>> type(data.speed)
<class 'activityio._util.types.Speed'>
>>> data.speed.base_unit
'm/s'
>>> data.speed.kph.mean()  # use a different unit
41.045473986415516

>>> data.dist.base_unit
'm'
>>> data.dist.miles[-1]
101.17480453266764

>>> data.alt.base_unit
'm'
>>> data.alt.ascent.sum()
1779.0
```

But note that you lose this functionality if you go changing column names:

```pycon
>>> data = data.rename(columns={'alt': 'altitude'})
>>> type(data.altitude)
<class 'pandas.core.series.Series'>
```

## API Notes

The main package is composed of sub-packages that contain the reading logic for the file format after which they're named. (e.g. `activityio.fit` is for parsing ANT/Garmin FIT files.) 

{'fraction_non_alphanumeric': 0.11076859843814221, 'fraction_numerical': 0.07603781339909577, 'mean_word_length': 3.299469964664311, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 105, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '848115', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1540, 'n_words': 575}