This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set sizes | |
plt.figure(figsize=(10,10)) | |
plt.rcParams.update({'font.size': 20}) | |
# Plot histogram | |
plt.hist(df['Glucose']) | |
# Labels | |
plt.xlabel('Glucose') | |
plt.ylabel('Count') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set sizes | |
plt.figure(figsize=(25,5)) | |
plt.rcParams.update({'font.size': 20}) | |
# Same plot as before | |
plt.plot(df['DateTime'], df['Glucose'], '.') | |
# Plot smoothed data | |
plt.plot(filtered, filteres[:,1], 'r') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filteres = lowess(df['Glucose'], df['DateTime'], is_sorted=True, frac=0.015, it=0) #0.025 | |
filtered = pd.to_datetime(filteres[:,0], format='%Y-%m-%dT%H:%M:%S') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import lowess from the statsmodels library | |
from statsmodels.nonparametric.smoothers_lowess import lowess |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate the mean and standard deviation of glucose. We will draw 3 lines on the plot: The mean, 1 standard deviation above the mean, and 1 standard deviation below the mean. | |
glucose_mean = np.mean(df['Glucose']) | |
up = np.mean(df['Glucose']) + np.std(df['Glucose']) | |
dw = np.mean(df['Glucose']) - np.std(df['Glucose']) | |
# Same plot as above | |
plt.figure(figsize=(25,5)) | |
plt.rcParams.update({'font.size': 20}) | |
plt.plot(df['DateTime'], df['Glucose'], '.', color = '#1f77b4') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Designate a figure size and font size | |
plt.figure(figsize=(25,5)) | |
plt.rcParams.update({'font.size': 20}) | |
# Plot | |
plt.plot(df['DateTime'], df['Glucose'], '.', color = '#1f77b4') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df.describe() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df = df.reset_index(drop=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We will use pd.to_datetime() to convert the Time column to a datetime object. We need to tell Python what the current format is. | |
df['DateTime'] = pd.to_datetime(df['DateTime'], format='%Y-%m-%dT%H:%M:%S') | |
# I would also like to make a new column, "Day", with just the Day of the DateTime column. | |
df['Day'] = df['DateTime'].dt.date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df |