So given a 1D array like
x = np.array([0,1,2,3,4,5,6,7,8,9])
I want to index multiple elements at the same time. For example instead of
x[1]
x[2]
I want to use
x[(1,2)]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: too many indices for array
It works for 1 2D array like for example
x = np.array([[1,2,3,4],[5,6,7,8],[7,6,8,9]])
>>> x
array([[1, 2, 3, 4],
[5, 6, 7, 8],
[7, 6, 8, 9]])
>>> x[(1,2),(1,3)]
array([6, 9])
>>> x[(1,2),:]
array([[5, 6, 7, 8],
[7, 6, 8, 9]])
So as you can see, for nd-arrays it works fine! Any way to do this kind of indexing for 1d-arrays?