0

I'm trying to find what elements are in a 2-D array, such as something along the lines below:

import numpy as np
a = np.array([[1,0,0],[1,3,0],[2,7,4]])
print find_element(a)
[0,1,2,3,4,7]

Is there a function that would do this for me?

0

1 Answer 1

4

You could use np.unique:

>>> a = np.array([[1,0,0],[1,3,0],[2,7,4]])
>>> np.unique(a)
array([0, 1, 2, 3, 4, 7])
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much m(_ _)m The np.unique function is just what I was looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.