[SciPy-User] Limit array to range

Florian Lindner mailinglists@xgm...
Mon Apr 1 11:30:05 CDT 2013


Hello,

I have two arrays from which I want to discard all rows where the first column 
is not within xrange:

This does perfectly what i want:

xrange = [-2, 3]
data1 = data1[ data1[:,0] >= xrange[0] ]
data1 = data1[ data1[:,0] <= xrange[1] ]
data2 = data2[ data2[:,0] >= xrange[0] ]
data2 = data2[ data2[:,0] <= xrange[1] ]

But I can hardly believe that this is the most elegant way. How would do such 
an easy task with numpy/scipy?


Regards,
Florian


More information about the SciPy-User mailing list