Answers for "numpy get unique values"

5

count unique values numpy

number_list = numpy.array([1, 1, 2, 3, 4, 4, 1])
(unique, counts) = numpy.unique(number_list, return_counts=True)
Posted by: Guest on June-20-2021
3

python unique array of array numpy

>>> import numpy as np
>>> x = np.array([[1, 1], [2,3], [3,4]])
>>> np.unique(x)
array([1, 2, 3, 4])
Posted by: Guest on April-29-2021
0

numpy array unique value counts

import numpy as np

x = np.array([1,1,1,2,2,2,5,25,1,1])
unique, counts = np.unique(x, return_counts=True)

print np.asarray((unique, counts)).T
Posted by: Guest on July-13-2021
0

how to find unique values in numpy array

>>> a = np.array(['a', 'b', 'b', 'c', 'a'])
>>> u, indices = np.unique(a, return_index=True)
>>> u
array(['a', 'b', 'c'], dtype='<U1')
>>> indices
array([0, 1, 3])
>>> a[indices]
array(['a', 'b', 'c'], dtype='<U1')
Posted by: Guest on August-03-2021
0

python .unique()

np.unique([1, 1, 2, 2, 3, 3])
array([1, 2, 3])
Posted by: Guest on August-21-2020

Code answers related to "numpy get unique values"

Python Answers by Framework

Browse Popular Code Answers by Language