Parse Garmin .fit wellness data, process it, and make DataFrame and NumPy arrays
Project description
fitparserx
A Python library for parsing Garmin .fit files and extracting wellness data (heart rate, stress level, respiration rate) into convenient Python structures (pandas DataFrame, NumPy array). These data are sourced from Garmin Wellness exports: either the daily export (Account Settings > Account Information > Export Wellness Data) or the full archive emailed via the Data Management page. Support for the Garmin activity data will be added in a future release.
Features
Uses Garmin .fit files decoded with the garmin_fit_sdk to:
- Extract proper datetimes and heart rate data.
- Optionally include respiration rate and stress level data.
- Converts the raw data into a pandas DataFrame or a NumPy array.
- Timezone‑aware datetime handling.
- Integrating estimated sleep data.
Installation
- (Optional) Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
- Install the package using pip:
pip install fitparserx
Usage
from fitparserx import FitParser
Initialize parser pointing to a directory or single file
Put your data into a data/ file. Otherwise, the parser goes through data in the current working directory. You can also point a path to a specific file.
mode='all' requires email prefix for .fit filenames
parser = FitParser(path="./data", email="user@example.com", mode="all")
DataFrame
Convert to a pandas DataFrame with datetimes and metrics:
# Only heart rate (default)
fit_df = parser.to_dataframe()
# Include stress level and respiration rate, fill missing with NaN
fit_df = parser.to_dataframe(add_metrics=["stress_level", "respiration_rate"], timezone="UTC")
Include the type of activity at each moment (e.g. 'sedentary' or 'walking') using the "add_state" flag:
fit_df = parser.to_dataframe(add_state=True)
Choose a filling strategy for missing data via the fill parameter. By default (fill=None), raw values are retained. If you set fill='NaN', any non-positive entries in "heart_rate", "stress_level" and "respiration_rate" will be replaced with NaN.
fit_df = parser.to_dataframe(fill='NaN')
Sleep Data
After downloading your user data from Data Management, you’ll find your sleep data in JSON files located in the directory DI_CONNECT/DI-Connect-Wellness. To add a Boolean column indicating sleep state (True for sleeping, no_sleep otherwise, defaults to False), call the add_sleep() method on the parser:
parser = FitParser(...)
parser.add_sleep(path="./sleep_data")
To get only the sleep time data, call the method parse_sleep_data():
sleeptimes = parser.parse_sleep_data(path="./sleep_data", timezone=timezone)
Note: parser.timezone is the timezone of the dataframe datetimes; setting option timezone in parse_sleep_data() doesn't change parser.timezone.
NumPy Array
fit_np = parser.to_numpy()
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fitparserx-0.1.5.tar.gz.
File metadata
- Download URL: fitparserx-0.1.5.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecd2cc81d68a91704f49d04025813206f4ab03e7ed3561c1684636cd2c04f994
|
|
| MD5 |
d0beb0152ea85826b80d39cc77fce813
|
|
| BLAKE2b-256 |
d5bac95d8bd51d04dc4a051f7a7bc6fae9c736147055aee506fc7d1c1ab746a9
|
File details
Details for the file fitparserx-0.1.5-py3-none-any.whl.
File metadata
- Download URL: fitparserx-0.1.5-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d65395a8637d66a83a843e6152e4a2c97f65514a412132fee961ce1525bfff60
|
|
| MD5 |
c066df990e7e1a805f16d3fa16db9735
|
|
| BLAKE2b-256 |
16dc068207e2ed6a11209e7666f0e3dc83c859e185a4c29b4b50c57723fa986b
|