ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U32'), dtype('<U32')) -> dtype('<U32')
- 错误代码(片段代码):
coef = np.where(coefs.get(DefaultArgs.C3), coefs.get(DefaultArgs.C3).get(row.C3), DefaultArgs.NONE)
if coef:
return (1 - row.CP) * coef + row.SR
- 错误原因:
np.where() 返回
numpy.ndarray
类型的数据,所以运算错误,不太明白numpy为什么不返回原始类型的数据。
- 修改:
- 使用
float()
强转 - 或者使用
if...else..
三元运算都可以
- 使用