根据最小阈值或置信区间,计算与另一组相比,给定组中有多少样本得到了改进?

Compute how many samples have been improved, according to a minimum threshold or confidence interval, in a given set in comparison to another set?

我有以下数据框:

ID      VAL1    VAL2
Q2241   0.3333  0.3353
Q2242   0.5     0.5
Q2243   0.3333  0.3333
Q2244   0.2137  0.4792
Q2245   0.1429  0.2
Q2246   0.5     0.5
Q2247   0.4167  0.6667
Q2248   1       1
Q2249   0.125   0.0909
Q2250   0.2     0.2
Q2251   0.325   0.2667
Q2252   0.1667  0.2
Q2253   0.3333  0.25
Q2254   0.45    0.8333
Q2255   0.3333  0.5
Q2256   1       1
Q2257   0.5     0.51
Q2258   0.3929  0.3333
Q2259   0.3611  0.625

有没有一种方法可以正确计算给定数据帧中 VAL2VAL1 显着 higher/lower 的样本数 (ID)。 我正在寻找类似 t-test 的内容,其中度量给出的结果类似于以下示例:

Win Tie Loss        
64  36  137

其中:

Win: number of IDs where VAL2 is higher than VAL1 with some confidence interval  
Tie: number of IDs where VAL2 ~ VAL1 (no significant difference, 0.0001 for example) 
Loss: number of IDs where VAL2 is lower than VAL1 with some confidence interval
tol = 0.0001
win = (df.VAL2 > (df.VAL1 + tol)).sum()
loss = (df.VAL2 < (df.VAL1 - tol)).sum()
tie = ((df.VAL1 - df.VAL2).abs() <= tol).sum()

df = pd.DataFrame([{'Win': win, 'Tie':tie, 'Loss': loss}])
print (df)
#    Loss  Tie  Win
# 0     4    6    9