Created
October 10, 2018 11:42
-
-
Save adrialuzllompart/1b10e65daa2789c18f3d727d8d7c36ce to your computer and use it in GitHub Desktop.
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 bootstrap(data, col, st_dev=False, rep=1000): | |
if not st_dev: | |
means = [] | |
n = len(data) | |
for i in range(rep): | |
sample = data.sample(n=n, replace=True) | |
mean = sample[col].mean() | |
means.append(mean) | |
return pd.DataFrame(means, columns=['means']) | |
else: | |
st_devs = [] | |
n = len(data) | |
for i in range(rep): | |
sample = data.sample(n=n, replace=True) | |
st_dev = sample[col].std() | |
st_devs.append(st_dev) | |
return pd.DataFrame(stds, columns=['st_dev']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment