Add sumdurationsedentarybout of the fitbit_step sensor

Co-authored-by: Meng Li <AnnieLM1996@gmail.com>
pull/95/head
Mingze Cao 2020-04-02 13:36:54 -05:00
parent 1ce76a5380
commit 7d770c91f3
2 changed files with 7 additions and 2 deletions

View File

@ -119,7 +119,7 @@ STEP:
DAY_SEGMENTS: *day_segments
METRICS:
ALL_STEPS: ["sumallsteps", "maxallsteps", "minallsteps", "avgallsteps", "stdallsteps"]
SEDENTARY_BOUT: ["countsedentarybout", "maxdurationsedentarybout", "mindurationsedentarybout", "avgdurationsedentarybout", "stddurationsedentarybout"]
SEDENTARY_BOUT: ["countsedentarybout", "maxdurationsedentarybout", "mindurationsedentarybout", "avgdurationsedentarybout", "stddurationsedentarybout", "sumdurationsedentarybout"]
ACTIVE_BOUT: ["countactivebout", "maxdurationactivebout", "mindurationactivebout", "avgdurationactivebout", "stddurationactivebout"]
THRESHOLD_ACTIVE_BOUT: 10 # steps
INCLUDE_ZERO_STEP_ROWS: True

View File

@ -43,7 +43,7 @@ else:
minutesGroupedBy = resampledData.groupby(['local_date','active_sedentary','active_sedentary_groups'])['time_diff_minutes'].sum()
#Get Stats for all episodes in terms of minutes
statsMinutes = minutesGroupedBy.groupby(['local_date','active_sedentary']).agg([max,min,np.mean,np.std])
statsMinutes = minutesGroupedBy.groupby(['local_date','active_sedentary']).agg([max,min,np.mean,np.std,np.sum])
mux = pd.MultiIndex.from_product([statsMinutes.index.levels[0], statsMinutes.index.levels[1]],names=['local_date','active_sedentary'])
statsMinutes = statsMinutes.reindex(mux, fill_value=None).reset_index()
statsMinutes.set_index('local_date',inplace = True)
@ -82,6 +82,9 @@ else:
if("stddurationsedentarybout" in sedentary_bout):
finalDataset["step_" + str(day_segment) + "_stddurationsedentarybout"] = statsMinutes[statsMinutes['active_sedentary']=='sedentary']['std']
if("sumdurationsedentarybout" in sedentary_bout):
finalDataset["step_" + str(day_segment) + "_sumdurationsedentarybout"] = statsMinutes[statsMinutes['active_sedentary']=='sedentary']['sum']
if("maxdurationactivebout" in active_bout):
finalDataset["step_" + str(day_segment) + "_maxdurationactivebout"] = statsMinutes[statsMinutes['active_sedentary']== 'active']['max']
@ -94,6 +97,8 @@ else:
if("stddurationactivebout" in active_bout):
finalDataset["step_" + str(day_segment) + "_stddurationactivebout"] = statsMinutes[statsMinutes['active_sedentary']== 'active']['std']
#Exclude data when the total step count is ZERO during the whole epoch
if not include_zero_step_rows:
finalDataset["sumallsteps_aux"] = resampledData["steps"].resample("D").sum()