From 5fb25877e9bdf9023cfe0f29902ae5578108856f Mon Sep 17 00:00:00 2001 From: evanweenen Date: Fri, 11 Mar 2022 10:49:13 +0100 Subject: [PATCH] Correct excluding exercise from sleep times --- preprocess_dexcom.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/preprocess_dexcom.py b/preprocess_dexcom.py index 300d447..70c9dd0 100644 --- a/preprocess_dexcom.py +++ b/preprocess_dexcom.py @@ -531,15 +531,16 @@ def identify_hours(df): # exclude recovery during exercise ts_training.loc[ts_training['exercise'] & ts_training['recovery'], 'recovery'] = False - # exclude sleep during exercise - ts_training.loc[ts_training['exercise'] & ts_training['sleep'], 'sleep'] = False - df = pd.merge(df, ts_training, on=['RIDER', 'timestamp'], how='outer') df['exercise'] = df['exercise'].fillna(False) df['recovery'] = df['recovery'].fillna(False) df['wake'] = (df.local_timestamp.dt.time >= datetime.time(6)) & (df.local_timestamp.dt.time <= datetime.time(23,59,59)) df['sleep'] = (df.local_timestamp.dt.time < datetime.time(6)) & (df.local_timestamp.dt.time >= datetime.time(0)) + + # exclude sleep during exercise + df.loc[df['exercise'] & df['sleep'], 'sleep'] = False + return df def identify_days(df):