This should be simple task but I am ashamed to admit I'm stuck.
I have a numpy array, called X
:
X.shape
is (10,3)
and it looks like
[[ 0. 0. 13. ]
[ 0. 0. 1. ]
[ 0. 4. 16. ]
...,
[ 0. 0. 4. ]
[ 0. 0. 2. ]
[ 0. 0. 4. ]]
I would like to select the 1, 2 and 3rd row of this array, using the indices in this other numpy array, called idx
:
idx.shape
is (3,)
and it looks like [1 2 3]
When I try
new_array = X[idx]
or variations on this,
I get errors.
How does one index a numpy array using another numpy array that holds the indices?
Apologizes for such a basic question in advance.