Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 642 Bytes

how-to-get-unique-values-from-numpy-array.md

File metadata and controls

31 lines (25 loc) · 642 Bytes

How to get unique values from Numpy array

import numpy as np
a = np.array([1,1,2,1,2])
uniq = np.unique(a)
  • import numpy as np - load lib:Numpy module for Python
  • np.array - declare Numpy array
  • [1,1,2,1,2] - sample array
  • .unique( - returns unique values only from specified array
  • uniq - will contain array with unique values only

group: uniq

Example:

import numpy as np
a = np.array([1,1,2,1,2])
uniq = np.unique(a)
print(uniq)
print(type(uniq))
[1 2]
<class 'numpy.ndarray'>

link_youtube: https://youtu.be/fIWckky7DIU