Reputation: 6693
Probably this is a dummy question! But I simply can't find the answer!
For the following array np.arange(-3,3,1.2)
I get this:
array([-3. , -1.8, -0.6, 0.6, 1.8])
and for this I want to get an index array like the following:
array([0, 1, 2, 3, 4])
Thanks in advance.
Upvotes: 1
Views: 146
Reputation: 58885
You can do:
a = np.array([-3. , -1.8, -0.6, 0.6, 1.8])
indices = np.arange(a.shape[0])
Upvotes: 1