Skip to content

Instantly share code, notes, and snippets.

@ThonyPrice
Created April 25, 2019 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThonyPrice/c8f1e026ab0ee24a0e3baa65ce1e2f50 to your computer and use it in GitHub Desktop.
Save ThonyPrice/c8f1e026ab0ee24a0e3baa65ce1e2f50 to your computer and use it in GitHub Desktop.
Medium - Get started analysing your CGM data
# Inspect samples closer than average
import numpy as np
import matplotlib.pyplot as plt
expected_diff = timedelta(minutes=4, seconds=30)
close_samples_idxs = np.where(z['t_diff'] < expected_diff)[0]
c_samples_times = z.iloc[close_samples_idxs, :]['t_diff']
c_samples_times = c_samples_times.apply(lambda x: x.seconds)
c_samples_glucose_diff =\
z.iloc[close_samples_idxs, :]['glucose'].values.astype(int)\
- z.iloc[close_samples_idxs+1, :]['glucose'].values.astype(int)
plt.scatter(c_samples_times, c_samples_glucose_diff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment