This file contains 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
def readfile(filename): | |
with open(filename) as f: | |
df = pd.read_html(f)[0] | |
df.columns = ['date', 'views'] | |
df['date'] = df['date'].apply(lambda x:dateutil.parser.parse(x)) | |
df = df.set_index('date') | |
df['day_of_week'] = df.index.map(lambda t:t.dayofweek) | |
df['max_weekly_value'] = df.views-pd.rolling_max(df.views, 7)==0 | |
return df | |
weekdays = ['Mondays', 'Tuesdays', 'Wednesdays', 'Thursdays', 'Fridays', 'Saturdays', 'Sundays'] |
This file contains 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
#observed data | |
popsize = 10000.0 | |
infected_data = np.array([ 7, 10, 11, 11, 13, 14, 14, 13, 14, 16, 18, 18, 20, 21, 22, 23, 23, 24, 25, 23]) | |
T = len(infected_data) | |
I0 = 7 | |
R0 = 5 | |
# priors |
This file contains 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 csv | |
titanic = open('titanic.txt', "rb") | |
reader = csv.reader(titanic) | |
prefix_list = ["Mr ", "Mrs", "Mis"] # used to determine if passanger's name includes a prefix. Using 3 chars because of Mr. | |
# There are several demographic details we can count passengers and survivors by, this is a dictionary to map them out along with col number in the file. |
This file contains 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
#!/usr/bin/env python | |
import binascii, sys, json | |
import version, tnetstring, flow | |
from datetime import datetime | |
def create_har(flows): | |
return { | |
"log":{ |