Unique Values from NumPy Array

المشرف العام

Administrator
طاقم الإدارة
Here is a quick example of how to get a unique value list from a numpy array.

from __future__ import print_function
import numpy as np

values = [['a', 'b', 'c'],
['e', 'b', 'd'],
['a', 'b', 'c']]
np_array = np.array(values)
print (np.unique(np_array[:,1], return_index=False))

# should see: ['b']


Enjoy!
Copyright AJC


أكثر...
 
أعلى