>>> a = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]]) >>> a array([[ 1, 2, 3, 4], [ 5, 6, 7, 8], [ 9, 10, 11, 12]]) >>> a[a[:,0] > 3] # select rows where first column is greater than 3 array([[ 5, 6, 7, 8], [ 9, 10, 11, 12]]) >>> a[a[:,0] > 3][:,np.array([True, True, False, True])] # select columns array([[ 5, 6, 8], [ 9, 10, 12]]) # fancier equivalent of the previous >>> a[np.ix_(a[:,0] > 3, np.array([True, True, False, True]))] array([[ 5, 6, 8], [ 9, 10, 12]])
For an explanation of the obscure np.ix_() see fooobar.com/questions/969964 / ...
Finally, we can simplify by specifying a list of columns instead of a tedious boolean mask:
>>> a[np.ix_(a[:,0] > 3, (0,1,3))] array([[ 5, 6, 8], [ 9, 10, 12]])