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
# 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) |
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
data[0:15] |
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
data |
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
data = pd.read_csv('test_file.csv') |
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 numpy as np | |
import pandas as pd | |
import datetime as datetime | |
import matplotlib.pyplot as plt |
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 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 |
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
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() |
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
latarray = np.array(df['lat']) | |
longarray = np.array(df['long']) | |
usmap.scatter(longarray, latarray, latlon=True, color='lime', s=20) | |
plt.show() |
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
usmap.readshapefile('st99_d00', name='states', drawbounds=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
usmap = Basemap(projection='lcc', llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,lat_1=33,lat_2=45,lon_0=-95) |