Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Exercise data handling library

Project Description

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

Stability

Please note this package is still very much an alpha release, so breaking changes are likely.

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:

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

NOTE substitute 'example.srm' with a path to your own activity file.

But you can also call sub-packages directly:

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

data in the above example 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:

>>> type(data)
<class 'activityio._types.activitydata.ActivityData'>
>>> data.head(5)
          temp  lap   dist  alt  cad  pwr  speed  hr
time
00:00:00  26.1    1  1.027   67    0    0  1.027  71
00:00:01  26.1    1  2.721   67    0    0  1.694  71
00:00:02  26.2    1  4.415   67    0    0  1.694  71
00:00:03  26.2    1  6.331   67    0    0  1.916  71
00:00:04  26.2    1  8.469   67    0    0  2.138  75
>>> data.normpwr()
249.54104255943844
>>> type(data.speed)
<class 'activityio._types.columns.Speed'>
>>> data.speed.base_unit
'm/s'
>>> data.speed.kph.mean()  # use a different unit
38.485063801685477
>>> data.dist.base_unit
'm'
>>> data.dist.miles[-1]
134.78580023361226
>>> data.alt.base_unit
'm'
>>> data.alt.ascent.sum()
1898.0
```

But NOTE you lose this functionality if you go changing column names

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

The ultimate logic is defined in a _reading module, which provides two functions: gen_records and read_and_format.

  • gen_records is a generator function for iterating over the data-points in a file. The rows of the data table if you like. A “record” is a dictionary object.
  • read_and_format uses the above generator to return an ActivityData object.

read_and_format is available at the top-level of a sub-package aliased as read; so reading in a file looks like srm.read('path_to_file.srm'). gen_records is imported under the same name.

There are also some useful tools provided in module by the same name.

Release History

Release History

This version
History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
activityio-0.0.3.tar.gz (57.3 kB) Copy SHA256 Checksum SHA256 Source Apr 4, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting