import dcor as dc
import numpy as np
import codecs
file = codecs.open('E:/PycharmProjects/pythonProject/test1.csv','rb')
lines = file.readlines()
file.close()
row = []
column = []
result = []
for line in lines:
line = line.decode()
row.append(line.split(','))
row = np.array(row)
row_float = row.astype(np.float)
for i in range(100):
a = row_float[:,i]
b = row_float[:,-1]
result.append(dc.distance_correlation(a,b))
np.savetxt("E:/PycharmProjects/pythonProject/result.txt", result, fmt='%f',delimiter=',')
print(result)
按列读取csv,并计算dcor
最新推荐文章于 2023-05-09 18:50:02 发布