numpy中的数据类型转换,使用函数astype(),不能直接改原数据的dtype
b = np.array([1, 2, 3, 4])
print(b.dtype)
b = b.astype('float64')
print(b)
print(b.dtype)
'''
int32
[1. 2. 3. 4.]
float64
'''
b = np.array([1, 2, 3, 4])
print(b.dtype)
b = b.astype('float64')
print(b)
print(b.dtype)
'''
int32
[1. 2. 3. 4.]
float64
'''