试图用np.around,将数组的小数控制三位
DataSetsD = np.around(DataSetsD, decimals=3)
产生如下错误:
AttributeError: ‘float’ object has no attribute ‘rint’
可通过.astype(float)强制把数组数据类型转换成float解决
DataSetsD = (DataSets[:,:72]/Base).astype(float)
DataSetsD = np.around(DataSetsD, decimals=3)
本文介绍在使用np.around函数控制数组小数位数时遇到的AttributeError错误,并提供解决方案,通过astype(float)将数据类型转换为浮点数,成功避免了错误并实现了预期的精度控制。
1万+

被折叠的 条评论
为什么被折叠?



