Skip to content

Instantly share code, notes, and snippets.

@ThonyPrice
Created April 25, 2019 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ThonyPrice/adf3b29968717fc7cdbe2ba4e83ee73a to your computer and use it in GitHub Desktop.
Save ThonyPrice/adf3b29968717fc7cdbe2ba4e83ee73a to your computer and use it in GitHub Desktop.
Medium - Get started analysing your CGM data
z = df.copy(deep=True)
z = z.join(pd.get_dummies(z['Status']), how='left')
day_map = ['Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun']
z['weekday'] = z.index.weekday
z = z[['weekday', 'glucose']]
z = z.resample('D').mean()
z.sort_values('weekday', inplace=True)
z.dropna(inplace=True)
z['weekday'] = z['weekday'].apply(lambda x: day_map[int(x)])
_ = plt.figure(figsize=(16, 6))
ax = sns.violinplot(x="weekday", y="glucose", data=z)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment