天天看點

關于Numpy更新後舊用法剔除報錯問題,Deprecated in NumPy 1.20; for more details and guidance

Numpy出現問題

因為今天更新了Numpy的最新版導緻了之前的用法失效

需要用上最新用法

本來我的傳回值是這樣

return np.array(df).astype(np.float)      

問題如下:

DeprecationWarning: np.float is a deprecated alias for the builtin

float. To silence this warning, use float by itself. Doing this

will not modify any behavior and is safe. If you specifically wanted

the numpy scalar type, use np.float64 here.

Deprecated in NumPy 1.20; for more details and guidance:

https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

return np.array(df).astype(np.float)

貌似是因為版本的問題

然後

我們就去官網康康

關于Numpy更新後舊用法剔除報錯問題,Deprecated in NumPy 1.20; for more details and guidance
關于Numpy更新後舊用法剔除報錯問題,Deprecated in NumPy 1.20; for more details and guidance

從圖檔上看的話

修改為下即可:

return np.array(df, dtype=float)      

或者

return np.array(df).astype(np.float64)      

這樣就不會報錯了~