天天看点

关于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)      

这样就不会报错了~