Skip to content

Commit

Permalink
refactor: swap _HourXX _WeekX in field name
Browse files Browse the repository at this point in the history
  • Loading branch information
chanshing committed Jun 11, 2024
1 parent 47021de commit 5beeee4
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/stepcount/stepcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ def main():
info['ENMO(mg)_Weekend'] = enmo_summary['weekend_avg']
info['ENMO(mg)_Weekday'] = enmo_summary['weekday_avg']
info.update({f'ENMO(mg)_Hour{h:02}': enmo_summary['hour_avgs'].loc[h] for h in range(24)})
info.update({f'ENMO(mg)_WeekendHour{h:02}': enmo_summary['hour_weekend_avgs'].loc[h] for h in range(24)})
info.update({f'ENMO(mg)_WeekdayHour{h:02}': enmo_summary['hour_weekday_avgs'].loc[h] for h in range(24)})
info.update({f'ENMO(mg)_Hour{h:02}_Weekend': enmo_summary['weekend_hour_avgs'].loc[h] for h in range(24)})
info.update({f'ENMO(mg)_Hour{h:02}_Weekday': enmo_summary['weekday_hour_avgs'].loc[h] for h in range(24)})

# ENMO summary, adjusted
enmo_summary_adj = summarize_enmo(data, exclude_wear_below=args.exclude_wear_below, exclude_first_last=args.exclude_first_last, adjust_estimates=True)
info['ENMOAdjusted(mg)'] = enmo_summary_adj['avg']
info['ENMOAdjusted(mg)_Weekend'] = enmo_summary_adj['weekend_avg']
info['ENMOAdjusted(mg)_Weekday'] = enmo_summary_adj['weekday_avg']
info.update({f'ENMOAdjusted(mg)_Hour{h:02}': enmo_summary_adj['hour_avgs'].loc[h] for h in range(24)})
info.update({f'ENMOAdjusted(mg)_Weekend_Hour{h:02}': enmo_summary_adj['hour_weekend_avgs'].loc[h] for h in range(24)})
info.update({f'ENMOAdjusted(mg)_Weekday_Hour{h:02}': enmo_summary_adj['hour_weekday_avgs'].loc[h] for h in range(24)})
info.update({f'ENMOAdjusted(mg)_Hour{h:02}_Weekend': enmo_summary_adj['weekend_hour_avgs'].loc[h] for h in range(24)})
info.update({f'ENMOAdjusted(mg)_Hour{h:02}_Weekday': enmo_summary_adj['weekday_hour_avgs'].loc[h] for h in range(24)})

# Steps summary
steps_summary = summarize_steps(Y, model.steptol, exclude_wear_below=args.exclude_wear_below, exclude_first_last=args.exclude_first_last)
Expand Down Expand Up @@ -174,11 +174,11 @@ def main():
info['Steps95thAt'] = steps_summary['ptile_at_avgs']['p95_at']
# hour-of-day averages
info.update({f'Steps_Hour{h:02}': steps_summary['hour_steps'].loc[h] for h in range(24)})
info.update({f'Steps_Weekend_Hour{h:02}': steps_summary['weekend_hour_steps'].loc[h] for h in range(24)})
info.update({f'Steps_Weekday_Hour{h:02}': steps_summary['weekday_hour_steps'].loc[h] for h in range(24)})
info.update({f'Steps_Hour{h:02}_Weekend': steps_summary['weekend_hour_steps'].loc[h] for h in range(24)})
info.update({f'Steps_Hour{h:02}_Weekday': steps_summary['weekday_hour_steps'].loc[h] for h in range(24)})
info.update({f'Walking(mins)_Hour{h:02}': steps_summary['hour_walks'].loc[h] for h in range(24)})
info.update({f'Walking(mins)_Weekend_Hour{h:02}': steps_summary['weekend_hour_walks'].loc[h] for h in range(24)})
info.update({f'Walking(mins)_Weekday_Hour{h:02}': steps_summary['weekday_hour_walks'].loc[h] for h in range(24)})
info.update({f'Walking(mins)_Hour{h:02}_Weekend': steps_summary['weekend_hour_walks'].loc[h] for h in range(24)})
info.update({f'Walking(mins)_Hour{h:02}_Weekday': steps_summary['weekday_hour_walks'].loc[h] for h in range(24)})

# Steps summary, adjusted
steps_summary_adj = summarize_steps(Y, model.steptol, exclude_wear_below=args.exclude_wear_below, exclude_first_last=args.exclude_first_last, adjust_estimates=True)
Expand Down Expand Up @@ -226,11 +226,11 @@ def main():
info['Steps95thAtAdjusted'] = steps_summary_adj['ptile_at_avgs']['p95_at']
# hour-of-day averages
info.update({f'StepsAdjusted_Hour{h:02}': steps_summary_adj['hour_steps'].loc[h] for h in range(24)})
info.update({f'StepsAdjusted_Weekend_Hour{h:02}': steps_summary_adj['weekend_hour_steps'].loc[h] for h in range(24)})
info.update({f'StepsAdjusted_Weekday_Hour{h:02}': steps_summary_adj['weekday_hour_steps'].loc[h] for h in range(24)})
info.update({f'StepsAdjusted_Hour{h:02}_Weekend': steps_summary_adj['weekend_hour_steps'].loc[h] for h in range(24)})
info.update({f'StepsAdjusted_Hour{h:02}_Weekday': steps_summary_adj['weekday_hour_steps'].loc[h] for h in range(24)})
info.update({f'WalkingAdjusted(mins)_Hour{h:02}': steps_summary_adj['hour_walks'].loc[h] for h in range(24)})
info.update({f'WalkingAdjusted(mins)_Weekend_Hour{h:02}': steps_summary_adj['weekend_hour_walks'].loc[h] for h in range(24)})
info.update({f'WalkingAdjusted(mins)_Weekday_Hour{h:02}': steps_summary_adj['weekday_hour_walks'].loc[h] for h in range(24)})
info.update({f'WalkingAdjusted(mins)_Hour{h:02}_Weekend': steps_summary_adj['weekend_hour_walks'].loc[h] for h in range(24)})
info.update({f'WalkingAdjusted(mins)_Hour{h:02}_Weekday': steps_summary_adj['weekday_hour_walks'].loc[h] for h in range(24)})

# Cadence summary
cadence_summary = summarize_cadence(Y, model.steptol, exclude_wear_below=args.exclude_wear_below, exclude_first_last=args.exclude_first_last)
Expand Down Expand Up @@ -404,8 +404,8 @@ def _mean(x, min_wear=None, dt=None):

# hour of day averages, 24-hour profile
hour_avgs = hourly.groupby(hourly.index.hour).mean().reindex(range(24))
hour_weekend_avgs = hourly[hourly.index.weekday >= 5].pipe(lambda x: x.groupby(x.index.hour).mean()).reindex(range(24))
hour_weekday_avgs = hourly[hourly.index.weekday < 5].pipe(lambda x: x.groupby(x.index.hour).mean()).reindex(range(24))
weekend_hour_avgs = hourly[hourly.index.weekday >= 5].pipe(lambda x: x.groupby(x.index.hour).mean()).reindex(range(24))
weekday_hour_avgs = hourly[hourly.index.weekday < 5].pipe(lambda x: x.groupby(x.index.hour).mean()).reindex(range(24))

return {
'avg': avg,
Expand All @@ -415,8 +415,8 @@ def _mean(x, min_wear=None, dt=None):
'daily': daily,
'minutely': minutely,
'hour_avgs': hour_avgs,
'hour_weekend_avgs': hour_weekend_avgs,
'hour_weekday_avgs': hour_weekday_avgs,
'weekend_hour_avgs': weekend_hour_avgs,
'weekday_hour_avgs': weekday_hour_avgs,
}


Expand Down

0 comments on commit 5beeee4

Please sign in to comment.