body.exercise: add cardio summary, move cross trainer to a separate file
This commit is contained in:
parent
eb14d5988d
commit
f02c572cc0
2 changed files with 58 additions and 8 deletions
50
my/body/exercise/cardio.py
Normal file
50
my/body/exercise/cardio.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
'''
|
||||
Cardio data, filtered from Endomondo and inferred from other data sources
|
||||
'''
|
||||
from ...core.pandas import check_dataframe as cdf
|
||||
|
||||
import pandas as pd # type: ignore
|
||||
|
||||
|
||||
CARDIO = {
|
||||
'Running',
|
||||
'Running, treadmill',
|
||||
'Cross training',
|
||||
'Walking',
|
||||
'Skating',
|
||||
'Spinning',
|
||||
'Skiing',
|
||||
'Table tennis',
|
||||
'Rope jumping',
|
||||
}
|
||||
# todo if it has HR data, take it into the account??
|
||||
NOT_CARDIO = {
|
||||
'Other',
|
||||
}
|
||||
|
||||
|
||||
@cdf
|
||||
def endomondo_cardio() -> pd.DataFrame:
|
||||
assert len(CARDIO.intersection(NOT_CARDIO)) == 0, (CARDIO, NOT_CARDIO)
|
||||
|
||||
from ..endomondo import dataframe as EDF
|
||||
df = EDF()
|
||||
|
||||
# not sure...
|
||||
# df = df[df['heart_rate_avg'].notna()]
|
||||
|
||||
is_cardio = df['sport'].isin(CARDIO)
|
||||
not_cardio = df['sport'].isin(NOT_CARDIO)
|
||||
neither = ~is_cardio & ~not_cardio
|
||||
# if neither -- count, but warn? or show error?
|
||||
|
||||
# todo error about the rest??
|
||||
# todo append errors?
|
||||
df.loc[neither, 'error'] = 'Unexpected exercise type, please mark as cardio or non-cardio'
|
||||
df = df[is_cardio | neither]
|
||||
|
||||
return df
|
||||
|
||||
|
||||
def dataframe():
|
||||
return endomondo_cardio()
|
Loading…
Add table
Add a link
Reference in a new issue