Skip to content

Instantly share code, notes, and snippets.

View rlmacsween's full-sized avatar

Roddy MacSween rlmacsween

  • Cambridge, UK
View GitHub Profile
@rlmacsween
rlmacsween / andersen.py
Created June 4, 2019 19:33
Andersen's analysis
def parse_statement(s):
a, b = s.split(' = ')
A, x = a[:-1], a[-1]
B, y = b[:-1], b[-1]
return (A, x, B, y)
def do_andersen(statements, iterations):
statements = [parse_statement(s) for s in statements]
pt = {}
from collections import Counter
import pandas as pd
df = pd.read_hdf('training.h5')
g = df.groupby('slug')
def get_sample(slug):
return df.ix[g.groups[slug]]