Use numpy.where and numpy.delete in combination
>>> v = np.array(range(25)).reshape(5,5)
>>> v
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]])
>>> np.delete(v, np.where(v>22)[1], 1)
array([[ 0, 1, 2],
[ 5, 6, 7],
[10, 11, 12],
[15, 16, 17],
[20, 21, 22]])
>>> np.delete(v, np.where(v>18)[0], 1)
array([[ 0, 1, 2],
[ 5, 6, 7],
[10, 11, 12],
[15, 16, 17],
[20, 21, 22]])
>>> np.delete(v, np.where(v>18)[0], 0)
array([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]])
>>>
Recommended Posts