Add sumdurationsedentarybout of the fitbit_step sensor
Co-authored-by: Meng Li <AnnieLM1996@gmail.com>pull/95/head
parent
1ce76a5380
commit
7d770c91f3
|
@ -119,7 +119,7 @@ STEP:
|
||||||
DAY_SEGMENTS: *day_segments
|
DAY_SEGMENTS: *day_segments
|
||||||
METRICS:
|
METRICS:
|
||||||
ALL_STEPS: ["sumallsteps", "maxallsteps", "minallsteps", "avgallsteps", "stdallsteps"]
|
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"]
|
ACTIVE_BOUT: ["countactivebout", "maxdurationactivebout", "mindurationactivebout", "avgdurationactivebout", "stddurationactivebout"]
|
||||||
THRESHOLD_ACTIVE_BOUT: 10 # steps
|
THRESHOLD_ACTIVE_BOUT: 10 # steps
|
||||||
INCLUDE_ZERO_STEP_ROWS: True
|
INCLUDE_ZERO_STEP_ROWS: True
|
||||||
|
|
|
@ -43,7 +43,7 @@ else:
|
||||||
minutesGroupedBy = resampledData.groupby(['local_date','active_sedentary','active_sedentary_groups'])['time_diff_minutes'].sum()
|
minutesGroupedBy = resampledData.groupby(['local_date','active_sedentary','active_sedentary_groups'])['time_diff_minutes'].sum()
|
||||||
|
|
||||||
#Get Stats for all episodes in terms of minutes
|
#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'])
|
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 = statsMinutes.reindex(mux, fill_value=None).reset_index()
|
||||||
statsMinutes.set_index('local_date',inplace = True)
|
statsMinutes.set_index('local_date',inplace = True)
|
||||||
|
@ -82,6 +82,9 @@ else:
|
||||||
if("stddurationsedentarybout" in sedentary_bout):
|
if("stddurationsedentarybout" in sedentary_bout):
|
||||||
finalDataset["step_" + str(day_segment) + "_stddurationsedentarybout"] = statsMinutes[statsMinutes['active_sedentary']=='sedentary']['std']
|
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):
|
if("maxdurationactivebout" in active_bout):
|
||||||
finalDataset["step_" + str(day_segment) + "_maxdurationactivebout"] = statsMinutes[statsMinutes['active_sedentary']== 'active']['max']
|
finalDataset["step_" + str(day_segment) + "_maxdurationactivebout"] = statsMinutes[statsMinutes['active_sedentary']== 'active']['max']
|
||||||
|
|
||||||
|
@ -94,6 +97,8 @@ else:
|
||||||
if("stddurationactivebout" in active_bout):
|
if("stddurationactivebout" in active_bout):
|
||||||
finalDataset["step_" + str(day_segment) + "_stddurationactivebout"] = statsMinutes[statsMinutes['active_sedentary']== 'active']['std']
|
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
|
#Exclude data when the total step count is ZERO during the whole epoch
|
||||||
if not include_zero_step_rows:
|
if not include_zero_step_rows:
|
||||||
finalDataset["sumallsteps_aux"] = resampledData["steps"].resample("D").sum()
|
finalDataset["sumallsteps_aux"] = resampledData["steps"].resample("D").sum()
|
||||||
|
|
Loading…
Reference in New Issue