Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to specify data on pearson correlation heatmap?

I have a pearson correlation heat map coded, but its showing data from my dataframe which i dont need.

is there a way to specify which columns i’d like to include?

thanks in advance

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

pearson correlation heatmap

sb.heatmap(df['POPDEN', 'RoadsArea', 'MedianIncome', 'MedianPrice', 'PropertyCount', 'AvPTAI2015', 'PTAL'].corr(), annot=True, fmt='.2f')

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-54-832fc3c86e3e> in <module>
----> 1 sb.heatmap(df['POPDEN', 'RoadsArea', 'MedianIncome', 'MedianPrice', 'PropertyCount', 'AvPTAI2015', 'PTAL'].corr(), annot=True, fmt='.2f')

TypeError: list indices must be integers or slices, not tuple
df.cov().round(3)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-79-34a86e96b161> in <module>
----> 1 df.cov().round(3)

TypeError: cov() missing 1 required positional argument: 'self'

>Solution :

You can filter the dataframe before calculating correlation

sns.heatmap(df[['POPDEN', 'RoadsArea', 'MedianIncome', 'MedianPrice', 'PropertyCount', 'AvPTAI2015', 'PTAL']].corr(), annot=True, fmt='.2f')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading