[Numpy-discussion] Masking an array with another array
Thu Apr 23 00:16:15 CDT 2009
On Wed, Apr 22, 2009 at 04:21:05PM -0500, Gökhan SEVER wrote:
> Could you please give me some hints about how to mask an array using
> another arrays like in the following example.
> In : a = arange(5)
> In : a
> Out: array([0, 1, 2, 3, 4])
> and my secondary array is "b"
> In : b = array([2,3])
> What I want to do is to mask a with b values and get an array of:
> array([False, False, True, True, False], dtype=bool)
This is an operation on 'sets': you are testing if members of a are 'in'
b. Generally, set operations on arrays can be found in
numpy.lib.arraysetops. I believe what you are interested in is
More information about the Numpy-discussion