from numpy import *
eps = 0.1
#ASSUMING the second arrow is sorted (otherwise sort it first)
a= array(
    [[1, 1.2, 3],     
    [2, 2.2, 3], 
    [3, 2.25, 1], 
    [4, 2.28, 4],
    [5, 3.2, 8], 
    [6, 4.2, 10],
    [7, 4.21, 3], 
    [8, 4.25, 4], 
    [9, 4.28, 1],
    [10, 5.2, 10],
    ])
# expected result
# a= [[1, 1.2, 3],
#     [3, 2.25, 1],
#     [5, 3.2, 8],
#     [9, 4.28, 1],
#     [10, 5.2, 10],
#     ]
n = shape(a)[0]
b = a[:,1]
a1 = a[ (diff(b)<eps) ]
#indexes of some False that could be True.
#these indexes should be checked backwards
#and evtl. added to a1
indexes = where((diff(b)<eps)==False)[0][1:]
for index in indexes:
    if b[index] - b[index-1]<eps:
        a1 = vstack( (a1,a[index,:]) )
#sort array
a1 = a1[lexsort( (a1[:,1],a1[:,1]))]
groups = where(diff(a1[:,1])>eps)[0]
i = 0
# get min of groups
for g in groups:
    ag = a1[i:g+1,2]
    Ag = a1[i:g+1,:]
    if i == 0:
        a2 = Ag [ ag == min(ag) ]
    else:
        a2 = vstack( (a2, Ag [ ag == min(ag) ] ) )
    i = g+1
#add last group
ag = a1[g+1:,2]
Ag = a1[g+1:,:]    
a2 = vstack( (a2, Ag [ ag == min(ag) ]) )
#the elements that build no groups
result = a[ in1d(a[:,0], [ int(i) for i in a[:,0] if i not in a1[:,0] ])  ] 
# add the elements of a2, these are the minimal elements of each group
result = vstack( (result, a2) )
# sort the result (optional)
result = result[lexsort( (result[:,0], result[:,0]))]
print "final result\n", result
这是此代码的输出
In [1]: run filter.py
final result
[[  1.     1.2    3.  ]
 [  3.     2.25   1.  ]
 [  5.     3.2    8.  ]
 [  9.     4.28   1.  ]
 [ 10.     5.2   10.  ]]