#* Statistical tests for differences in the features across groups from scipy import stats all_t = list() all_p = list() for case in range(len(feature_names)): sub_df = df_long[df_long.Feature == feature_names[case]] g1 = sub_df[sub_df['Group'] == 0]['Value'].values g2 = sub_df[sub_df['Group'] == 1]['Value'].values t, p = stats.ttest_ind(g1, g2) all_t.append(t) all_p.append(p)