array = np.int(array)TypeError:只能将length-1数组转换为Python标量

时间:2017-09-05 19:36:05

标签: python-2.7 numpy math

array = df.as_matrix()
array = np.int(array)

我试过了:

array = np.int(array)

for:

array[i][10]/5

但得到了:

  

array = np.int(array)TypeError:只有length-1数组可以转换为Python标量????

1 个答案:

答案 0 :(得分:0)

尝试:

>>> a = np.random.normal(20, 5, size=(2,2))
array([[ 24.04255462,  24.24954137],
       [ 14.64894245,  16.17946985]])
>>> a = a.astype(int)
>>> a
array([[24, 24],
       [14, 16]])

检查docs