Activity

Constructor

Activity(records[, laps, summary])

Represents a running activity.

Attributes and underlying data

Activity.records

The records (time series) of the Activity.

Activity.laps

The lap data of the Activity.

Activity.summary

The summary data of the Activity.

Activity.records_unique

Unique rows in the records DataFrame.

Activity.has_position

Return whether the records DataFrame contains GPS coordinates.

Activity.latlons

GPS coordinate records as a list of [lat, lon] lists.

Activity.lonlats

GPS coordinates as a list of [lon, lat] lists.

Methods

Activity.has_streams(*field_names)

Return whether all given streams exist in the records DataFrame.

IO / conversion

Activity.from_fit(file_obj)

Construct an Activity from a .fit file.

Activity.from_tcx(file_obj)

Construct an Activity from a .tcx file.

Activity.from_gpx(file_obj)

Construct an Activity from a .gpx file.

Activity.from_csv(filepath_or_buffer)

Construct an Activity from a .csv file.

Field accessors

heartandsole provides field-specific methods under various accessors. These are separate namespaces within Activity that only apply to specific data types. Each accessor works with Activity data that bears its name:

  • In the records DataFrame, column labels must exactly match the corresponding accessor name.

  • In the laps DataFrame, column labels should be of the form <accessor_name>_<stat_name> or <stat_name>_<accessor_name>.

  • In the summary Series, row labels should be of the form <accessor_name>_<stat_name> or <stat_name>_<accessor_name>.

Data Type

Accessor

Datetime

timestamp

Time in Seconds

time

GPS Coordinates

position

Distance

distance

Speed

speed

Elevation

elevation

Decimal Grade

grade

Heart Rate

heartrate

Step Cadence

cadence

Common field accessor methods/properties

All field accessors have the following properties at Activity.<field>.<property>

stream

The column of the record DataFrame for this field.

laps

A subset of the laps DataFrame for the field.

summary

A subset of the summary Series for the field.

Timestamp field accessor

Datetime-specific methods and attributes are provided under the Activity.timestamp accessor.

Activity.timestamp.start([source])

Return start time as a datetime.

Activity.timestamp.end([source])

Return end time as a datetime.

Activity.timestamp.elapsed([source])

Return elapsed time as a timedelta.

Activity.timestamp.ensure_aware([tz_local])

Ensure all recognized timestamp data is timezone-aware.

Time field accessor

Integer time-specific methods and attributes are provided under the Activity.time accessor.

Activity.time.records_from_timestamps([inplace])

Time records calculated from timestamp records.

Activity.time.elapsed([source])

Return elapsed time in seconds.

Activity.time.timer([source])

Return total time, in seconds, when the device was active.

GPS coordinate field accessors

GPS coordinate-specific methods and attributes are provided under the Activity.lat and Activity.lon accessors.

Activity.lat.center

The midpoint of the coordinate stream's extents.

Activity.lon.center

The midpoint of the coordinate stream's extents.

Distance field accessor

Cumulative distance-specific methods and attributes are provided under the Activity.distance accessor.

Activity.distance.total([source])

Return total distance in meters.

Activity.distance.records_from_position([...])

Cumulative distance records calculated from GPS coordinate records.

Speed field accessor

Speed-specific methods and attributes are provided under the Activity.speed accessor.

Elevation field accessor

Elevation-specific methods and attributes are provided under the Activity.elevation accessor.

Activity.elevation.gain([source])

Return total elevation gain in meters.

Activity.elevation.loss([source])

Return total elevation loss in meters.

Grade field accessor

Decimal grade-specific methods and attributes are provided under the Activity.grade accessor.

Heart rate field accessor

Heart rate-specific methods and attributes are provided under the Activity.heartrate accessor.

Cadence field accessor

Cadence-specific methods and attributes are provided under the Activity.cadence accessor.