Skip to content

Instantly share code, notes, and snippets.

@alyssafrazee
Last active August 29, 2015 14:20
Show Gist options
  • Save alyssafrazee/95f577cd37d3866eb1c7 to your computer and use it in GitHub Desktop.
Save alyssafrazee/95f577cd37d3866eb1c7 to your computer and use it in GitHub Desktop.
import pandas as pd
from numpy.random import randint
from numpy import median, percentile
my_data = pd.read_csv('dataset.csv')
n = len(my_data)
num_bootstrap_samples = 1000
bootstrap_results = []
for b in xrange(num_bootstrap_samples):
sampled_data = my_data.iloc[randint(0, n, size=n)]
med = median(sampled_data['income'])
bootstrap_results.append(med)
ci_lower = percentile(bootstrap_results, 2.5)
ci_upper = percentile(bootstrap_results, 97.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment