List Highest Correlation Pairs from a Large Correlation Matrix in Pandas?

后端 未结 13 587
心在旅途
心在旅途 2020-12-22 17:45

How do you find the top correlations in a correlation matrix with Pandas? There are many answers on how to do this with R (Show correlations as an ordered list, not as a lar

13条回答
  •  清歌不尽
    2020-12-22 18:16

    Use the code below to view the correlations in the descending order.

    # See the correlations in descending order
    
    corr = df.corr() # df is the pandas dataframe
    c1 = corr.abs().unstack()
    c1.sort_values(ascending = False)
    

提交回复
热议问题