Reputation: 2449
I'm sorry, I think this is a really trivial question, but...
I have a binary Numpy array, mostly zeros with a few ones. I would like to find the coordinates of all the locations where myArray[myArray == 1]
Please can you help me? Thanks
Upvotes: 1
Views: 88
Reputation: 101
If you are using a list (rather than a numpy array), this answer uses enumerate in both a loop and list comprehension: https://stackoverflow.com/a/17202481/1160876
Upvotes: 0
Reputation: 114108
np.where(myArray==1)
I guess, should work (assuming its numpy array, based on your indexing example)
Upvotes: 2