-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathno6.py
More file actions
19 lines (14 loc) · 684 Bytes
/
Copy pathno6.py
File metadata and controls
19 lines (14 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pandas as pd
import numpy as np
train = pd.read_csv("train.csv")
weather_cols = train.drop(columns=["ID", "date", "cluster_id", "electricity_consumption"]).columns
corr_matrix = train[weather_cols].corr()
corr_pairs = (corr_matrix.abs()
.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(bool))
.stack()
.reset_index()
.rename(columns={"level_0":"Variable 1",
"level_1":"Variable 2",
0:"|Pearson r|"})
.sort_values("|Pearson r|", ascending=False))
print(corr_pairs[corr_pairs["|Pearson r|"] > 0.80])