Numpy广播比较报告“'bool' object has no attribute 'sum'”在处理大数据帧时报错

问题描述

我使用 numpy 广播从 Pandas 数据框中获取差异矩阵。我发现在处理大型数据帧时,它报告“'bool' 对象没有属性 'sum'”错误。在处理小数据帧时,它运行良好。

我在以下链接中发布了两个 csv 文件large file small file

import numpy as np
import pandas as pd
df_small = pd.read_csv(r'test_small.csv',index_col='Key')
df_small.fillna(0,inplace=True)
a_small = df_small.to_numpy()
matrix = pd.DataFrame((a_small != a_small[:,None]).sum(2),index=df_small.index,columns=df_small.index) 
print(matirx)

运行时,我可以得到差分矩阵。

enter image description here

切换到大文件时,报如下错误。有人知道为什么会这样吗?

编辑:numpy 版本是 1.19.5

np.__version__
'1.19.5'

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...