我正在尝试对值数组进行规范化,但是当我将其放入numpy数组时,它将自动将值转换为整数。代码如下:
import numpy as np
data = np.array([[1,2],[3,1],[3,5],[4,6],[3,4]])
s = np.std(data[:,0])
m = np.mean(data[:,0])
temp = (data[:,0] - m)
temp /= s
print(temp)
data[:,0] = temp
print(data)
结果是这样的:
[-0.86266219 -1.40182605 0.75482941 1.29399328 0.21566555]
[[ 1 0]
[ 3 -1]
[ 3 0]
[ 4 1]
[ 3 0]]
为什么我将其放入numpy时会自动转换为整数?我该如何解决?