Efficiently removing duplicate rows from a 2-dimensional Numeric array

Terry Reedy tjreedy at udel.edu
Fri Jul 20 05:35:10 CEST 2007

"Alex Mont" <t-alexm at windows.microsoft.com> wrote in message 
news:76EEE12626B7A84EBACE67EC513AE53D060F8CE9 at WIN-MSG-20.wingroup.windeploy.ntdev.microsoft.com...
I have a 2-dimensional Numeric array with the shape (2,N) and I want to
remove all duplicate rows from the array. For example if I start out

I want to end up with

If you can define a 1-1 map of rows to ints (or even float or strings), you 
can put intsnumbers into a set and then convert (unique) items back to 
rows.  For example above, the obvious 10*r[0] + r[1] would do.  So would 
chr(r[0]) + chr(r[1]).  More generally, you need the min and max of the 
second numbers and not have them be too far apart/


More information about the Python-list mailing list