[SciPy-user] Selecting items from an array

Noel O'Boyle noel.oboyle2 at mail.dcu.ie
Tue Sep 27 09:49:29 CDT 2005


Newbie question:

I'm trying to select items from a vector using a mask.

For example:
X = array([100,56,44,99])
mask = ([0,1,0,1])

I want to create:
newX = array([56,99])
i.e. only those elements of X for which mask is true.

scipy.take will do this but I need to find the indices of all of the 1's
in mask. It must be possible to do this with scipy, but how?

Regards,
Noel



More information about the SciPy-user mailing list