1# Create correlation matrix
2corr_matrix = df.corr().abs()
3
4# Select upper triangle of correlation matrix
5upper = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(np.bool))
6
7# Find index of feature columns with correlation greater than 0.95
8to_drop = [column for column in upper.columns if any(upper[column] > 0.95)]