我有一个皮尔逊相关热图编码,但它显示的数据从我的数据,我不需要。
是否有一种方法可以指定我希望包括哪些列?
提前感谢

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 tupledf.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'发布于 2022-05-26 18:06:04
在计算相关性之前,可以先过滤数据。
sns.heatmap(df[['POPDEN', 'RoadsArea', 'MedianIncome', 'MedianPrice', 'PropertyCount', 'AvPTAI2015', 'PTAL']].corr(), annot=True, fmt='.2f')发布于 2022-05-26 18:21:52
#对于多列选择,请使用双方括号。我希望这能成功
sb.heatmap(df[['POPDEN', 'RoadsArea', 'MedianIncome', 'MedianPrice', 'PropertyCount', 'AvPTAI2015', 'PTAL']].corr(), annot=True, fmt='.2f')https://stackoverflow.com/questions/72396189
复制相似问题