Skip to content Skip to sidebar Skip to footer

Python: How To Find The Value Of A Number In A Numpy Array?

I have the following array: a = np.array([[0,1,2,3,4,5,6,7],[8,9,10,11,12,13,14,15],[16,17,18,19,20,21,22,23],[24,25,26,27,28,29,30,31],[32,33,34,35,36,37,38,39,],[40,41,42,43,44,4

Solution 1:

The shortest way (gives you the indices in oposite order) is

np.argwhere(a==13)

gives:

array([[1, 5]])

Post a Comment for "Python: How To Find The Value Of A Number In A Numpy Array?"