r = np.zeros((rows, rows))
ms = data.mean(axis=1)
datam = np.zeros_like(data)
for i in range(rows):
    datam[i] = data[i] - ms[i]
datass = scipy.stats.ss(datam, axis=1)
for i in range(rows):
    for j in range(i, rows):
        r_num = np.add.reduce(datam[i] * datam[j])
r_den = np.sqrt(datass[i] * datass[j])
r[i, j] = min(r_num / r_den, 1.0)
Нахождение корреляционной матрицы