Skip to content

Instantly share code, notes, and snippets.

@ThonyPrice
Created May 15, 2019 20:58
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/b9d205bd00da508dbb88f00359e2c6fc to your computer and use it in GitHub Desktop.
Save ThonyPrice/b9d205bd00da508dbb88f00359e2c6fc 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['chunk'] = 'Second'
z['chunk'].iloc[:(z.shape[0]//2)] = 'First'
z.sort_values(['weekday', 'chunk'], 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(
data=z, x="weekday", y="glucose", hue='chunk', split=True,
palette="Set2", inner='quartile')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment