[Numpy-discussion] Numpy Array of dtype=object with strings and floats question

Darryl Wallace darryl.wallace@prosensus...
Fri Nov 6 14:56:57 CST 2009


What I'm doing is importing some data from excel and sometimes there are
strings in the worksheet.  Often times a user will use an empty cell or a
string to represent data that is missing.

e.g.
from numpy import *
mixedArray=array([1, 2, '', 3, 4, 'String'], dtype=object)

Two questions:
1) Is there a quick way to find the elements in the array that are the
strings without iterating over each element in the array?

or

2) Could I quickly turn it into a masked array of type float where all
string elements are set as missing points?

I've been struggling with this for a while and can't come across a method
that will all me to do it without iterating over each element.

Any help or pointers in the right direction would be greatly appreciated.

Thanks,
Darryl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091106/afede90d/attachment.html 


More information about the NumPy-Discussion mailing list