【发布时间】:2020-05-10 13:20:19
【问题描述】:
我有 3 个 xlsx 文件,分别命名为数据、矢量和标题。
- 数据包含 5x5 个条目,this is data dataframe looks
- 向量包含 5x1 个条目,this is vector dataframe looks
- 标题包含 5x1 条目,this is heading dataframe looks
我从数据文件中取出每一列并找到它与向量的相关性
for i,j in data.iteritems():
col=j
coef, p = spearmanr(col, vector)
alpha = 0.05
if p < alpha:
print('\n\nSpearmans correlation coefficient: %.3f' % coef)
print(f' column {[i]} method are correlated (reject H0) p=%.3f' % p)
这给了我输出
Spearmans 相关系数:1.000。 column[0] 方法是相关的(拒绝 H0) p=0.000
Spearmans 相关系数:1.000。 column[2] 方法是相关的(拒绝 H0) p=0.000
Spearmans 相关系数:1.000。 column[3] 方法是相关的(拒绝 H0) p=0.000
我想指向标题的特定列,以便我想要的输出是
Spearmans 相关系数:1.000。红色方法相关(拒绝 H0) p=0.000
Spearmans 相关系数:1.000。绿色方法是相关的(拒绝 H0) p=0.000
Spearmans 相关系数:1.000。蓝色方法是相关的(拒绝 H0)p=0.000
任何参考资料或资源都会有所帮助。 谢谢
【问题讨论】:
标签: python python-3.x pandas dataframe data-science