This is the code we used in this notebook;
def reshuffle(dataf):
return (dataf
.sample(36)
.reset_index(drop=True)
.assign(sleep=lambda d: np.where(d.index < 15, 'deprived', 'normal')))
def calc_diff(dataf):
agg = (dataf
.groupby('sleep')
.agg(mean_unit_tests=('passed_unit_tests', np.mean),
mean_asserts=('passed_asserts', np.mean),
mean_user_stories=('tackled_user_stories', np.mean),)).T
return agg['deprived'] - agg['normal']
n = 1000
results = np.zeros((n, 3))
for i in range(n):
results[i, :] = calc_diff(reshuffle(df))
df_diff = pd.DataFrame(results,
columns=['diff_unit_tests',
'diff_asserts',
'diff_user_stories'])