I want to find the index/location of a randomly chosen number in a 1D NumPy array within the array itself, but when I try the following:
a = np.array(np.linspace(1,10,10))
b = np.random.choice(a)
print(a.index(b))
It doesn't work and can't figure out where the problem is. Does anyone have an idea?
Thanks in advance!
EDIT: how do you only index the randomly chosen value if the values in the NumPy array are identical, for example:
a = np.array(np.linspace(10,10,10))