How to access index in an array

Question:

I would like to access indices instead of element value

import numpy as np

data=np.arange(20,60)
def number_of_dies_probed(inp_arr)-> np.array:

    inp_arr=inp_arr.flatten()
    enter_numbers=int(input('Enter number of dices to be probed:'))#for example input value 8
    vb=((len(inp_arr))/enter_numbers)

    dies_to_probe=(inp_arr[np.arange(0,inp_arr.shape[0],int(vb))])
    return dies_to_probe
mn=number_of_dies_probed(data)
print(mn)

current output:

 [20 25 30 35 40 45 50 55]   

requirement:instead of element values I need index values like this below.
required output:

[0,5,10,15,20,25,30,35]
Asked By: Bhar Jay

||

Answers:

return np.in1d(inp_arr, dies_to_probe).nonzero()[0]

returns:
array([ 0,  5, 10, 15, 20, 25, 30, 35], dtype=int64)
Answered By: Tom McLean
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.