np.astype()
作者:互联网
1.作用:就是转换numpy数组的数据类型
举个例子
arr = np.arange((10))
print(arr, arr.dtype, sep="\n")
===================================
[0 1 2 3 4 5 6 7 8 9]
int32 #可以看到,他的数据类型为 int32
np.astype()
arr = arr.astype("float32")
print(arr, arr.dtype, sep="\n")
===================================
[0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]
float32 #可以看到数据类型转换成了 float32
用法:arr.astype(“具体的数据类型”)
标签:arr,sep,数据类型,astype,np,float32 来源: https://blog.csdn.net/qq_41621362/article/details/94405846