heartandsole.ActivityΒΆ
- class heartandsole.Activity(records, laps=None, summary=None)[source]
Represents a running activity.
Composed of one mandatory DataFrame representing record data (rows=records, columns=fields), one optional DataFrame representing lap data (rows=laps, columns=stats), and one optional Series representing summary data (each element a summary statistic for the entire activity).
- Parameters
records (pandas.DataFrame) β data records from an activity. Each column of the DataFrame corresponds to a data stream of some field, and each row is a record corresponding to a certain point in time.
laps (pandas.DataFrame) β lap data from the activity. Each row represents one lap and the index corresponds to lap number. Optional.
summary (pandas.Series) β summary data for the activity. Row values could be anything. Optional.
Examples
Constructing an Activity from a records DataFrame.
>>> df = pd.DataFrame(data=dict( ... timestamp=[datetime.datetime(2019, 9, 1, second=i) for i in range(5)], ... distance=[i * 3.0 for i in range(5)], ... elevation=[1.0 * i for i in range(5)], ... )) >>> act = Activity(df) >>> act.records timestamp distance elevation time 0 2019-09-01 00:00:00 0.0 0.0 0 1 2019-09-01 00:00:01 3.0 1.0 1 2 2019-09-01 00:00:02 6.0 2.0 2 3 2019-09-01 00:00:03 9.0 3.0 3 4 2019-09-01 00:00:04 12.0 4.0 4 5 2019-09-01 00:00:05 15.0 5.0 5 >>> act.summary Series([], dtype: object) >>> act.laps Empty DataFrame Columns: [] Index: []
Methods
from_csv(filepath_or_buffer)Construct an Activity from a .csv file.
from_fit(file_obj)Construct an Activity from a .fit file.
from_gpx(file_obj)Construct an Activity from a .gpx file.
from_tcx(file_obj)Construct an Activity from a .tcx file.
has_streams(*field_names)Return whether all given streams exist in the records DataFrame.
Attributes
Return whether the records DataFrame contains GPS coordinates.
The lap data of the Activity.
GPS coordinate records as a list of [lat, lon] lists.
GPS coordinates as a list of [lon, lat] lists.
The records (time series) of the Activity.
Unique rows in the records DataFrame.
The summary data of the Activity.