簡體   English   中英

如何在皮爾遜相關熱圖上指定數據?

[英]how to specify data on 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'

您可以在計算相關性之前過濾數據框

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

#對於多列選擇使用雙方括號。 我希望這會奏效

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM