Skip to content

Instantly share code, notes, and snippets.

View endlesspint8's full-sized avatar

Reginald Eps endlesspint8

View GitHub Profile
sample Python code of running a shuffling and sampling of two populations
# http://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
def new_value(orig_inputs, new_min, new_max, old_value):
old_min = min(orig_inputs)
old_max = max(orig_inputs)
old_range = old_max - old_min
new_range = new_max - new_min
new_value = ((old_value - old_min) * new_range / old_range) + new_min
return new_value
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
%matplotlib inline
# team xref information
team_xref = pd.read_csv('data/team_xref.csv', sep=';')
print team_xref.shape
def craft_import_match(year, overall, overall_growth, craft, craft_growth, imp, imp_growth):
print "starting metrics:"
print "year:", year
print "overall %d BBLS and %3.3f percent growth" % (overall, overall_growth)
print "craft %d BBLS & %2.3f percent growth" % (craft, craft_growth)
print "import %d BBLS & %2.3f percent growth" % (imp, imp_growth)
print "\nyear\toverall_bbl\tcraft_bbl\timport_bbl"
while craft < imp:
year += 1
import numpy as np
def lat_path(x):
grid = (x+1) * (x+1)
test_m = np.zeros(grid).reshape(x+1, x+1)
for row in range(x+1):
for col in range(x+1):
import csv
dutch_dict = {}
# stop words
with open('stopwords/stopwords_table_wTrans.csv', 'r') as f:
reader = csv.reader(f)
reader.next()
for row in reader:
dutch_dict[row[1]] = row[5]