Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: no longer round walking metrics; avoid spamming console with hour-of-day metrics #122

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/stepcount/stepcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import json
import hashlib
import re
import numpy as np
import pandas as pd
import joblib
Expand Down Expand Up @@ -242,7 +243,11 @@ def main():

# Print
print("\nSummary\n-------")
print(json.dumps(info, indent=4, cls=NpEncoder))
print(json.dumps(
# exclude hour-of-day metrics to avoid spamming the console
{k: v for k, v in info.items() if not re.search(r'_Hour\d{2}', k)},
indent=4, cls=NpEncoder
))
print("\nEstimated Daily Stats\n---------------------")
print(daily.set_index('Date').drop(columns='Filename'))
print("\nEstimated Daily Stats (Adjusted)\n---------------------")
Expand Down Expand Up @@ -451,8 +456,9 @@ def _tdelta_to_str(tdelta):

# daily stats
daily = pd.concat([
daily_walk.round().astype(pd.Int64Dtype()),
daily_walk,
daily.round().astype(pd.Int64Dtype()),
# convert timedelta to human-friendly format
daily_ptile_at.rename(columns={
'p05_at': 'Steps5thAt',
'p25_at': 'Steps25thAt',
Expand All @@ -466,21 +472,17 @@ def _tdelta_to_str(tdelta):
hour_steps = hourly.groupby(hourly.index.hour).agg(_mean).reindex(range(24))
hour_walks = hourly_walk.groupby(hourly_walk.index.hour).agg(_mean).reindex(range(24))

# convert units
# round steps
total = nanint(np.round(total))
minutely = minutely.round().astype(pd.Int64Dtype())
hourly = hourly.round().astype(pd.Int64Dtype())
daily_avg = nanint(np.round(daily_avg))
daily_med = nanint(np.round(daily_med))
daily_min = nanint(np.round(daily_min))
daily_max = nanint(np.round(daily_max))
total_walk = nanint(np.round(total_walk))
daily_walk_avg = nanint(np.round(daily_walk_avg))
daily_walk_med = nanint(np.round(daily_walk_med))
daily_walk_min = nanint(np.round(daily_walk_min))
daily_walk_max = nanint(np.round(daily_walk_max))
daily_ptile_at_avg = daily_ptile_at_avg.map(_tdelta_to_str)
hour_steps = hour_steps.round().astype(pd.Int64Dtype())
# convert timedelta to human-friendly format
daily_ptile_at_avg = daily_ptile_at_avg.map(_tdelta_to_str)

return {
'total': total,
Expand Down
Loading