问题描述
我使用 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)
编辑:numpy 版本是 1.19.5
np.__version__
'1.19.5'
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)