If correlation is greater than 0.75 remove the column from dataframe of pandas

Viewed 15486

I have a dataframe name data for which I plotted correlation matrix by using

corr = data.corr()

I want if corr between two column is greater than 0.75, remove one of them from dataframe data. I tried some option

raw =corr[(corr.abs()>0.75) & (corr.abs() < 1.0)]

but it did not help, I need column number from raw for which value is nonzero. Basically some python command replacement of following R command

{hc=findCorrelation(corr,cutoff = 0.75)

hc = sort(hc)

data <- data[,-c(hc)]}

If anyone can help me to get command similar to above mention R command in python pandas, that would be helpful.

1 Answers
Related