ipyhealth is a Python3 library to parse, wrangle and plot Apple Health data from all Apple devices.
ipyhealth makes it easy for developers to obtain the Apple Health data, saved as four pandas dataframes:
- Samples: data that is recorded at a specific time, including HKQuantitySample (height, heart rate, energy consumed, etc.), HKCategorySample (user in bed, asleep, or awake) and HKCorrelation (food and blood pressure).
- Workouts: dataframe containing type (Walk, Run, Hike, Yoga, etc.), duration, energy burned and distance of a recorded workout.
- Activity Summary: dataframe containing the move, exercise and stand data for a given day.
- Routes: dataframe containing the location of the route file (.gpx file exported), the latitude, lonitude and elevation at different points of the route.
© ipyhealth contributors 2020 (see AUTHORS) under the MIT license.
Install using pip with:
pip install ipyhealth
Or install from Github using:
pip install git+https://github.com/mereldawu/ipyhealth.git
from ipyhealth.parser import AppleHealthParser
health_data = AppleHealthParser(
in_file = '/location/to/apple_health_export',
from_date = None, # date to start parsing, i.e. datetime(2020, 5, 1)
verbose = True, # print extract progress and success status, i.e. True/False
nprocs = 4 # number of CPUs to use
)
type(health_data.records) # pd.DataFrame
type(health_data.workouts) # pd.DataFrame
type(health_data.activities) #pd.DataFrame
type(health_data.routes) #pd.DataFrame
Download and extract the Apple Health data to a desired location:
- On your iPhone, open Health App.
- Click on your avatar > Scroll to the bottom > Export all health data (this takes some time).
- Select Save to Files (this is only available for iOS 13 and above, for lower verions of iOS save at a location where you can read it).
- Unzip the export.zip folder, which contains apple_health_export folder:
apple_health_export
├── export.xml (the main file that is parsed)
├── export_cda.xml (the Clinical Document Architecture file is not used)
├── workout_routes
├── route{timestamp}.gpx (the GPS data for the associated workout)
├──route_{timestamp}.gpx (these contain the location information)
├── export.xml (the main file that is parsed)
├── export_cda.xml (the Clinical Document Architecture file is not used)
├── workout_routes
├── route{timestamp}.gpx (the GPS data for the associated workout)
├──route_{timestamp}.gpx (these contain the location information)
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.