Skip to content

Instantly share code, notes, and snippets.

View brinnaebent's full-sized avatar

RunsData brinnaebent

View GitHub Profile
# 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)
data[0:15]
data = pd.read_csv('test_file.csv')
import numpy as np
import pandas as pd
import datetime as datetime
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# Read the data
df = pd.read_csv('thanksgiving-2015-poll-data.csv')
# List the pie types (you can see these by reading the Readme or viewing the columns of df using the command df.columns)
pielist = ['Apple', 'Buttermilk', 'Cherry', 'Chocolate', 'Coconut cream', 'Key lime', 'Peach', 'Pecan', 'Pumpkin', 'Sweet Potato']
# Make a dictionary and fill it with the count of each column/pie
from matplotlib.patches import Polygon
fig = plt.figure(figsize=(20,10))
plt.rcParams.update({'font.size': 20})
usmap = Basemap(llcrnrlon=-121,llcrnrlat=20,urcrnrlon=-62,urcrnrlat=51, projection='lcc',lat_1=32,lat_2=45,lon_0=-95)
usmap.readshapefile('st99_d00', name='states', drawbounds=True)
ax = plt.gca()
latarray = np.array(df['lat'])
longarray = np.array(df['long'])
usmap.scatter(longarray, latarray, latlon=True, color='lime', s=20)
plt.show()
usmap.readshapefile('st99_d00', name='states', drawbounds=True)
usmap = Basemap(projection='lcc', llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,lat_1=33,lat_2=45,lon_0=-95)