如何指定Pearson相关热图的数据?
我有一个Pearson相关热图编码了,但是它显示了我不需要的数据框中的数据。
有没有办法指定我想包含哪些列?
预先感谢
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'
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
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'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在计算相关性之前过滤数据框
You can filter the dataframe before calculating correlation
#对于多列选择,请使用双方括号。
我希望这会起作用
#for multiple column selection use double square brackets.
I hope this would work