{"id":37668257,"url":"https://github.com/evavanweenen/cycling-stats","last_synced_at":"2026-01-17T22:47:17.857Z","repository":{"id":65043774,"uuid":"581188720","full_name":"evavanweenen/cycling-stats","owner":"evavanweenen","description":"Calculate advanced cycling statistics from power and/or heart rate data","archived":false,"fork":false,"pushed_at":"2022-12-22T15:31:45.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-07T20:15:20.723Z","etag":null,"topics":["bike","cycling","cyclinganalytics","heartrate-analysis","power-analysis","statistics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evavanweenen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-22T14:04:57.000Z","updated_at":"2023-10-25T09:35:12.000Z","dependencies_parsed_at":"2023-01-13T15:22:32.239Z","dependency_job_id":null,"html_url":"https://github.com/evavanweenen/cycling-stats","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/evavanweenen/cycling-stats","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evavanweenen%2Fcycling-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evavanweenen%2Fcycling-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evavanweenen%2Fcycling-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evavanweenen%2Fcycling-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evavanweenen","download_url":"https://codeload.github.com/evavanweenen/cycling-stats/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evavanweenen%2Fcycling-stats/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bike","cycling","cyclinganalytics","heartrate-analysis","power-analysis","statistics"],"created_at":"2026-01-16T12:00:42.720Z","updated_at":"2026-01-16T12:00:54.870Z","avatar_url":"https://github.com/evavanweenen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cycling-stats - Calculate advanced cycling statistics from power and/or heart rate data\n\nCalculate statistics such as time spent in individualized heart rate and power zones, normalized power, intensity factor, training stress score, variability index, efficiency factor, chronic training load, acute training load and training stress balance, from heart rate and power meters.\n\n## Installation\nThe package is available under pypi:\n```\npip install cycling-stats\n```\n\n## Usage\nYou can use the package as follows. A simple example: you can import the function `training_stress_score` as follows.\n```python\nfrom cyclingstats.stats import training_stress_score\n```\n\nThe package requires that you have your data in a `pandas.DataFrame`. The following example illustrates when you have a time series from multiple separate training sessions, and you wish to calculate statistics separately for each day of cycling.\n\n```python\nimport pandas as pd\nfrom cyclingstats.stats import calc_hr_zones, calc_power_zones, agg_zones, agg_power \nfrom cyclingstats.stats import chronic_training_load, acute_training_load, training_stress_balance\n\n# read time series of power and/or heart rate\ndf = pd.read_csv(\"PATH_TO_YOUR_HEARTRATE_AND_POWER_DATA\")\ndf['date'] = pd.to_datetime(df['timestamp'].dt.date)\n# perform any other preprocessing steps here\n\n# ---------- zones\n# define LTHR and FTP to calculate custom Coggan heart rate and power zones\nLTHR = # TODO: fill in a number for the lactate threshold heart rate [bpm]\nFTP = # TODO: fill in a number for the functional threshold power [W]\n\nhr_zones = calc_hr_zones(LTHR)\npower_zones = calc_power_zones(FTP)\n\n# calculate hr and power zones\ndf_zones = df.groupby('date').apply(agg_zones, hr_zones=hr_zones, power_zones=power_zones)\n\n# ---------- power\ndf = df.set_index('timestamp')\n\n# calculate power statistics\ndf_power = df.groupby('date').apply(agg_power, FTP=FTP)\n\n# fill up dates for which we don't have an entry to get exponential weighted mean (ewm)\ndates = df_power.index\ndf_power = df_power.reindex(date_range)\n\n# calculate ctl, atl and tsb\ndf_power['chronic_training_load'] = chronic_training_load(df_power['training_stress_score'])\ndf_power['acute_training_load'] = acute_training_load(df_power['training_stress_score'])\ndf_power['training_stress_balance'] = training_stress_balance(df_power['chronic_training_load'], df_power['acute_training_load'])\n\n# get back to indices for which there is a training session\ndf_power = df_power.loc[dates]\n```\n\nIf you are running into problems, feel welcome to contact the author (evanweenen@ethz.ch).\n\n## License\nThis code is \u0026copy; E. van Weenen, 2022, and it is made available under the MIT license enclosed with the software.\n\nOver and above the legal restrictions imposed by this license, if you use this software for an academic publication then you are obliged to provide proper attribution. \n```\nE. van Weenen. cycling-stats: Calculate advanced cycling statistics from power and/or heart rate data, v0.1 (2022). github.com/evavanweenen/cycling-stats.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevavanweenen%2Fcycling-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevavanweenen%2Fcycling-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevavanweenen%2Fcycling-stats/lists"}