array默认是float64,不能作为另外一个array的index
inds = np.array([]) #默认float64
print(inds.dtype)
order = np.array([53])
order = order[inds]
print(order)
上面的报错如下:
IndexError: arrays used as indices must be of integer (or boolean) type
正确的应该是指定array为整型,然后该array才能作为另外的array的index。
inds = np.array([]).astype(np.int64)
print(inds.dtype)
order = np.array([53])
order = order[inds]
print(order)
输出:
int64
[]