Browse Source

Diy corr?

Petra Lamborn 5 years ago
parent
commit
18aaf160f1
1 changed files with 5 additions and 5 deletions
  1. 5
    5
      py/clustering.py

+ 5
- 5
py/clustering.py View File

@@ -13,11 +13,11 @@ def tqcorr(df):
13 13
     cols = df.columns
14 14
     ncols = len(cols)
15 15
     cdf = p.DataFrame(index = cols, columns = cols)
16
-    for c in tqdm(range(ncols)):
17
-        cind = cols[c]
18
-        cdf.loc[cind, cind] = 1
19
-        # for i in range(c + 1, ncols):
20
-        #     print("ZZZ")
16
+    for c in tqdm(cols):
17
+        cdf.loc[c, c] = 0
18
+    comb = combinations(cols, 2)
19
+    for c1, c2 in tqdm(comb):
20
+        cdf.loc[c1, c2] = 1 - df[c1].corr(df[c2])
21 21
     return cdf
22 22
 
23 23