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..
三元運算都可以
- 使用