Skip to content

Instantly share code, notes, and snippets.

@brinnaebent
Created November 17, 2020 14:23
Show Gist options
  • Save brinnaebent/5bd105d0da26818f15986f37a0441a15 to your computer and use it in GitHub Desktop.
Save brinnaebent/5bd105d0da26818f15986f37a0441a15 to your computer and use it in GitHub Desktop.
# Instantiate a new dataframe. We will call this one "df"
df = pd.DataFrame() # This creates an empty data frame
# Pull timestamp and glucose columns into the new, empty dataframe. We will change their names to "DateTime" and "Glucose"
df['DateTime'] = data['Timestamp (YYYY-MM-DDThh:mm:ss)']
# For glucose, we also want to change the data to a number. Right now, Python thinks the glucose column values are strings (you can think of a string as text). We will wrap the function in pd.to_numeric() to convert the column to numbers.
df['Glucose'] = pd.to_numeric(data['Glucose Value (mg/dL)'])
# The first 12 rows don't even have matching glucose + time values, so let's drop those
df.drop(df.index[:12], inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment