python - Indexing a numpy array with another array containing out of bounds values -
given following data array:
d=np.array([10,11,12,13,14]) and indexing array:
i=np.array([0, 2, 3, 6]) what way of indexing d i (d[i]) instead of index out of bounds error 6, get:
np.array([10, 12, 13])
maybe use i[i < d.size]] elements less length of d:
print(d[i[i < d.size]]) [10 12 13]
Comments
Post a Comment