[Numpy-discussion] Addressing arrays
Mon Jan 30 12:39:13 CST 2012
> You'd want to update your mask appropriately to get everything you
> want to select, one criteria at a time e.g.:
> mask = a[:,0] == 1
> mask &= a[:,1] == 1960
> mask = (a[:,0] == 1) & (a[:,1] == 1960)
> but be careful with the parens, & and | are normally high-priority
> bitwise operators and if you leave the parens out, it will try to
> bitwise-and 1 and a[:,1] and throw an error.
> If you've got a ton of parameters, you can combine these more
> aesthetically with:
> mask = (a[:,[0,1]] == [1, 1960]).all(axis=1)
Zach and Brett,
Many thanks -- that is exactly what I need.
More information about the NumPy-Discussion