Here are ways to handle conditions on columns or rows inspired by Zen Python.
In []: import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. ...
So, following the second tip:
a) the conditions of the column (s) applied to the row (s):
In []: a= arange(12).reshape(3, 4) In []: a Out[]: array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]) In []: a[2, logical_and(1== a[0, :], 5== a[1, :])]+= 12 In []: a Out[]: array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 21, 10, 11]])
b) the conditions for the row (s) applied to the column (s):
In []: a= aT In []: a Out[]: array([[ 0, 4, 8], [ 1, 5, 21], [ 2, 6, 10], [ 3, 7, 11]]) In []: a[logical_and(1== a[:, 0], 5== a[:, 1]), 2]+= 12 In []: a Out[]: array([[ 0, 4, 8], [ 1, 5, 33], [ 2, 6, 10], [ 3, 7, 11]])
Thus, I hope that it really makes sense to always be explicit when accessing columns and rows. The code is usually read by people with a different background.