You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.
counts_dict = {}
y = df_new[col_treatment]
trt = df_new[col_outcome]
for feat in feats:
bin_feat = str(feat) + '_bin'
counts1_t1 = df_new[(y == 1) & (trt == 1)][[feat, bin_feat]].groupby(bin_feat).count().rename(
columns={feat: 'counts_y1t1'})
counts1_t0 = df_new[(y == 1) & (trt == 0)][[feat, bin_feat]].groupby(bin_feat).count().rename(
columns={feat: 'counts_y1t0'})
counts0_t1 = df_new[(y == 0) & (trt == 1)][[feat, bin_feat]].groupby(bin_feat).count().rename(
columns={feat: 'counts_y0t1'})
counts0_t0 = df_new[(y == 0) & (trt == 0)][[feat, bin_feat]].groupby(bin_feat).count().rename(
columns={feat: 'counts_y0t0'})
# creating a dataframe with all of these results
counts_dict[feat] = pd.concat([counts1_t1, counts1_t0, counts0_t1, counts0_t0], axis=1).fillna(
0) + 1 # replace any empty slots with zeros (and add 1 to everything)
should be
counts_dict = {}
y = df_new[col_outcome]
trt = df_new[col_treatment]
for feat in feats:
bin_feat = str(feat) + '_bin'
counts1_t1 = df_new[(y == 1) & (trt == 1)][[feat, bin_feat]].groupby(bin_feat).count().rename(
columns={feat: 'counts_y1t1'})
counts1_t0 = df_new[(y == 1) & (trt == 0)][[feat, bin_feat]].groupby(bin_feat).count().rename(
columns={feat: 'counts_y1t0'})
counts0_t1 = df_new[(y == 0) & (trt == 1)][[feat, bin_feat]].groupby(bin_feat).count().rename(
columns={feat: 'counts_y0t1'})
counts0_t0 = df_new[(y == 0) & (trt == 0)][[feat, bin_feat]].groupby(bin_feat).count().rename(
columns={feat: 'counts_y0t0'})
# creating a dataframe with all of these results
counts_dict[feat] = pd.concat([counts1_t1, counts1_t0, counts0_t1, counts0_t0], axis=1).fillna(
0) + 1 # replace any empty slots with zeros (and add 1 to everything)
The text was updated successfully, but these errors were encountered: