python numpy indexerror: too many indices for array

import numpy as np

#data 原来数组
#arr_1 新数组
#将data的第一列赋值给arr_1的第一列


arr_1 = np.array((data.shape[0],5))

arr_1[:,0] = data[:,0]

#报错
#    arr_1[:,0] = data[:,0]#id
#IndexError: too many indices for array

#改为
arr_1 = np.zeros((data.shape[0],5))
arr_1[:,0] = data[:,0]
#正常运行

 

posted @ 2017-11-15 14:01  秋华  阅读(18243)  评论(0编辑  收藏  举报