Issue
I have a np.array of size (432, 432). I needed to find a value within this array which I have successfully done which has the index (162,19). I want to isolate the number '162' and then the number '19' to then carry on further with my function but am unsure of how to do this.
This function is looped over hundreds of times over different arrays, so each time it loops I get a different index from which I need to extract the numbers 'x' and 'y' to carry on with the rest of the function.
I know how to print the full index in the console, but can't seem to save the value of x and y separately as shown as the (x,y) index as integers.
Solution
(162,29)
is a python tuple
, similar to a list.
If
idx = (162, 29)
i,j = idx
i= idx[0]
all should work.
If arr
is your array
arr[idx]
gets the value at that index
arr[i,:] # a row
arr[:,j] # a column
Answered By - hpaulj
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.