[Numpy-discussion] iteration over arrays
Chris Fenton
chrisf at fagmed.uit.no
Mon Apr 28 03:31:03 EDT 2003
INTRO:
I am trying to use Jnumeric(jython numeric)for mixed arrays of int,
NONE, string, and user defined objects, mostly because of the easy to
use syntax and notation.
QUESTION:
Is there an easy way to generate a mask array from object type ?
pseudocode:
vector = array(['a',2,'b',None,None,None,'hello'])
>>> ['a',2,'b',None,None,None,'hello']
mask = equal(vector, isString)
>>> [1,0,1,0,0,0,1]
EXAMPLE:
vector = array([1,2,3,None,None,None,7])
>>>[1,2,3,None,None,None,7]
mask = equal(vector, None).astype(Int8)
>>>[0,0,0,1,1,1,0]
PS:
Why don't we have a boolean-(0,1)-1bit type ?
Chris Fenton
More information about the NumPy-Discussion
mailing list