Let an array:
a =np.array([[1,2],[3,-5],[6,-15],[10,7]])
to get lines with elements of the second column above -6 it’ s possible to do
>>> a[a[:,1]>-6]
array([[ 1, 2],
[ 3, -5],
[10, 7]])
but how to get lines with the second element between -6;3?
I tried:
>>> a[3>a[:,1]>-6]
and also (which raises an error):
>>> np.ma.masked_inside(a,-6,3)
which gives:
masked_array(data =
[[-- --]
[-- --]
[6 -15]
[10 7]],
mask =
[[ True True]
[ True True]
[False False]
[False False]],
fill_value = 999999)
but the result is not too clear
Thanks
jp
1 Answer