Skip to content

Instantly share code, notes, and snippets.

@chewxy
Created November 26, 2015 05:39
Show Gist options
  • Save chewxy/6b59cd3324fd5218f0e8 to your computer and use it in GitHub Desktop.
Save chewxy/6b59cd3324fd5218f0e8 to your computer and use it in GitHub Desktop.
Munges stuff from FitNotes, StrongLifts and MyFitnessPal
import pandas as pd
import numpy as np
fitnotesFile = "..."
strongLiftsFile = "..."
mfpFile = "..."
fn = pd.read_csv(fitnotesFile)
fn = fn.rename(columns={'Weight (kgs)': 'Weight'}) # cleanup names
grp = fn.groupby(['Date','Exercise']).agg({'Weight':[np.sum, np.mean], 'Reps': [np.sum, np.mean], 'Exercise': [np.size]})
unstacked = grp.unstack()
colNames = []
for c in unstacked.columns:
if c[0] == 'Exercise':
colNames.append('{} Sets'.format(c[2]))
else:
colNames.append('{} {}({})'.format(c[2], c[1], c[0]))
unstacked.columns = colNames
unstacked = unstacked.reset_index()
sl = pd.read_csv(strongLiftsFile) # already unstacked
workouts = pd.concat([sl, unstacked])
weights = pd.read_csv(mfpFile)
together = pd.merge(weights, workout, on='Date', how='left')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment