我用np.average(data['val'], weights=data['w'])计算加权平均,然后报错如下
TypeError: No loop matching the specified signature and casting was found for ufunc add
有遇到这个情况的吗?
1个回答
估计是dtype的问题,你把type转成float之类的试试
data['w'] = data['w'].astype(float)
data['val'] = data['val'].astype(float)