Issue
I have a numpy array like this:
a = [0,88,26,3,48,85,65,16,97,83,91]
How can I get the values at certain index positions in ONE step? For example:
ind_pos = [1,5,7]
The result should be:
[88,85,16]
Solution
Just index using you ind_pos
ind_pos = [1,5,7]
print (a[ind_pos])
[88 85 16]
In [55]: a = [0,88,26,3,48,85,65,16,97,83,91]
In [56]: import numpy as np
In [57]: arr = np.array(a)
In [58]: ind_pos = [1,5,7]
In [59]: arr[ind_pos]
Out[59]: array([88, 85, 16])
Answered By - Padraic Cunningham
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.