Skip to content

Commit

Permalink
Correct excluding exercise from sleep times
Browse files Browse the repository at this point in the history
  • Loading branch information
evavanweenen committed Mar 11, 2022
1 parent c8ca7ec commit 5fb2587
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions preprocess_dexcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5fb2587

Please sign in to comment.