Store and load rider power-profileΒΆ

This example illustrates how to store the information contained in a sksports.Rider instance.

print(__doc__)

# Authors: Guillaume Lemaitre <g.lemaitre58@gmail.com>
# License: MIT

We will use the sksports.Rider class to compute power-profile for the toy data sets.

from sksports.datasets import load_fit
from sksports import Rider

rider = Rider()
rider.add_activities(load_fit())

print('The computed activities are:\n {}'.format(rider.power_profile_))

Out:

The computed activities are:
                   2014-05-07 12:26:22         ...           2014-07-26 16:50:56
cadence 00:00:01            78.000000         ...                     60.000000
        00:00:02            64.000000         ...                     58.000000
        00:00:03            62.666667         ...                     56.333333
        00:00:04            62.500000         ...                     59.250000
        00:00:05            64.400000         ...                     61.000000
        00:00:06            64.500000         ...                     62.333333
        00:00:07            64.571429         ...                     63.571429
        00:00:08            64.625000         ...                     63.750000
        00:00:09            64.222222         ...                     63.444444
        00:00:10            62.000000         ...                     63.000000
        00:00:11            61.909091         ...                     62.363636
        00:00:12            62.083333         ...                     61.916667
        00:00:13            61.846154         ...                     62.076923
        00:00:14            64.928571         ...                     62.642857
        00:00:15            60.466667         ...                     63.400000
        00:00:16            65.437500         ...                     62.625000
        00:00:17            66.000000         ...                     61.823529
        00:00:18            65.888889         ...                     61.109223
        00:00:19            65.842105         ...                     60.468319
        00:00:20            65.550000         ...                     59.889806
        00:00:21            66.000000         ...                     59.364771
        00:00:22            66.136364         ...                     58.885922
        00:00:23            66.391304         ...                     58.447235
        00:00:24            66.625000         ...                     58.043689
        00:00:25            66.960000         ...                     57.671068
        00:00:26            67.307692         ...                     57.325803
        00:00:27            67.666667         ...                     57.004854
        00:00:28            67.964286         ...                     56.705617
        00:00:29            68.103448         ...                     56.425845
        00:00:30            68.233333         ...                     68.500000
...                               ...         ...                           ...
speed   01:51:14                  NaN         ...                      5.478008
        01:51:15                  NaN         ...                      5.478270
        01:51:16                  NaN         ...                      5.478586
        01:51:17                  NaN         ...                      5.478993
        01:51:18                  NaN         ...                      5.479495
        01:51:19                  NaN         ...                      5.480122
        01:51:20                  NaN         ...                      5.480738
        01:51:21                  NaN         ...                      5.481302
        01:51:22                  NaN         ...                      5.481879
        01:51:23                  NaN         ...                      5.482435
        01:51:24                  NaN         ...                      5.482988
        01:51:25                  NaN         ...                      5.483579
        01:51:26                  NaN         ...                      5.484132
        01:51:27                  NaN         ...                      5.484607
        01:51:28                  NaN         ...                      5.485022
        01:51:29                  NaN         ...                      5.485448
        01:51:30                  NaN         ...                      5.485894
        01:51:31                  NaN         ...                      5.486276
        01:51:32                  NaN         ...                      5.486645
        01:51:33                  NaN         ...                      5.486973
        01:51:34                  NaN         ...                      5.487264
        01:51:35                  NaN         ...                      5.487511
        01:51:36                  NaN         ...                      5.487729
        01:51:37                  NaN         ...                      5.487925
        01:51:38                  NaN         ...                      5.488108
        01:51:39                  NaN         ...                      5.488282
        01:51:40                  NaN         ...                      5.488451
        01:51:41                  NaN         ...                      5.488631
        01:51:42                  NaN         ...                      5.488807
        01:51:43                  NaN         ...                      5.488291

[40218 rows x 3 columns]

We can store and load the information using the to_csv and from_csv methods.

filename_rider = 'rider.csv'
rider.to_csv(filename_rider)

rider_reloaded = Rider.from_csv(filename_rider)

Clean the temporary csv file

import os
os.remove(filename_rider)

Total running time of the script: ( 1 minutes 48.334 seconds)

Gallery generated by Sphinx-Gallery