【问题标题】:Error make correlation and heatmap错误使相关性和热图
【发布时间】:2017-05-16 11:51:00
【问题描述】:

我想在数据集 titanic 上查看(幸存者、pclass、性别、年龄和票价)的相关性,有表:

Index([u'survived', u'pclass', u'sex', u'age', u'sibsp', u'parch', u'fare', 你'登船'],

correlation_matrix =np.zeros(shape=(5,5)) 矩阵 5x5

然后我运行它以将值从表添加到矩阵:

for i, field1 in enumerate(df.columns):
for j, field2 in enumerate(df.columns):
        correlation_matrix[i,j] = pearsonr(df[field1], df[field2])[0]

出错了:

enter image description here

【问题讨论】:

    标签: python pandas jupyter-notebook


    【解决方案1】:

    它抱怨 'ret' 是一个字符串,而您正试图将它除以 rcount,它可能是一个浮点数或整数。

    这看起来可能是重复的问题。

    Issue with seaborn in sublime

    【讨论】:

    • 我尝试使用这个:np.corrcoef(df['fare'], df['age']) 但不能超过 2 张桌子?我的意思是,我制作矩阵 5,5,然后我想从表中添加到矩阵值
    猜你喜欢
    • 2020-06-02
    • 2019-05-23
    • 1970-01-01
    • 1970-01-01
    • 2016-01-22
    • 2021-06-08
    • 1970-01-01
    • 2021-08-31
    • 2015-06-17
    相关资源
    最近更新 更多