我是 python 的新手,并试图对分为两个组(C2 和 S1)的多个列执行 Kruskal Wallis 测试。
到目前为止,我已经能够使用以下代码对单个列进行 Kruskal Wallis 测试。(我通过网络收集的)
import pandas as pd
df =pd.read_excel( 'C2_S1_sorted_2.xlsx')
#collected through internet
import scipy.stats as ss
data = [df.loc[ids, '3-HYDROXYPHENYLACETATE-DEGRADATION-PWY: 4-hydroxyphenylacetate degradation'].values for ids in df.groupby('Group').groups.values()]
H, p = ss.kruskal(*data)
p
我尝试使用“while 循环”来遍历所有列,但直到现在还不能这样做。我还在 StackOverflow 中解决了几乎所有与此相关的问题,但我无法解决我的问题。
谁能帮我做这件事?如果这是一个非常基本的问题,我很抱歉。
下面是我的数据的样子。
Group 1CMET2-PWY: N10-formyl-tetrahydrofolate biosynthesis 3-HYDROXYPHENYLACETATE-DEGRADATION-PWY: 4-hydroxyphenylacetate degradation 7ALPHADEHYDROX-PWY: cholate degradation (bacteria, anaerobic)
C2 889.944 0 0
C2 931.451 0 0
C2 795.362 0 0
C2 840.724 0 0
C2 732.173 0 0
C2 908.025 0.843261 0
C2 733.818 0.518661 0
C2 842.462 1.82225 0
C2 843.887 0 0
C2 823.395 0 0
C2 713.35 0.699201 0.534327
C2 859.136 0.604455 0
C2 871.477 0 0
C2 763.695 0 0
C2 835.966 0 0
C2 781.925 0 0
C2 1010.87 0 0
C2 936.106 0 0
C2 738.947 1.9034 0
C2 988.541 0 0
S1 838.256 0 0
S1 758.363 0 0
S1 1022.51 0 0
S1 1016.61 0 0
S1 908.64 0 0
S1 941.786 0 0
S1 999.038 0 0
S1 914.317 0 0
S1 1053.07 0 0
S1 876.61 0 0
S1 793.693 0 0
S1 916.2 0 0
S1 1108.61 0 0
S1 938.456 0 0
S1 825.406 0 0
S1 1332.52 0 0
S1 1198.65 0 0
S1 1005.4 0 0
S1 826.529 0 0
S1 1170.82 0.624429 0