[Numpy-discussion] Fwd: np.unique for one bi-dimensional array

Andreas Hilboll lists at hilboll.de
Wed Jul 25 10:50:48 EDT 2012


> Hi,
>
> would like to identify unique pairs of numbers in two arrays o in one
> bi-dimensional array, and count the observation
>
> a_clean=array([4,4,5,4,4,4])
> b_clean=array([3,5,4,4,3,4])
>
> and obtain
> (4,3,2)
> (4,5,1)
> (5,4,1)
> (4,4,2)
>
> I solved with tow loops but off course there will be a faster solution.
>
> I was checking also
>
> for np.unique but i did not find how to apply for a bi-dimensional array.
> or
> Concatenate the two arrays
> a_concatenate=array([4_3,4_5,5_4,4_4,4_3,4_4]), then np.unique, then
> split again.
>
> Any other/faster solutions?
> In bash I usually unique command
> Thanks in advance

I'd try np.histogram2d, but probably only because I don't know np.unique.

A.




More information about the NumPy-Discussion mailing list