Keith Goodman wrote:
> I have a list x
>
>
>>> x
>>>
> [[1, None], [2, 3]]
>
> that I generate outside of numpy (with plain python). What is the best
> way to convert x into an array? This doesn't work
>
>
>>> asarray(x)
>>>
>
> array([[1, None],
> [2, 3]], dtype=object) <-- I'm hoping for something like
> dtype=float64
>
> Is there something better than None to represent missing values so
> that when I convert to numpy arrays (actually matrices) I'll be all
> set? (I could use -99, but that would be even more embarrassing than
> my python skills.)
>
You can use a masked array specifically, or use nan's for missing values
and just tell Python you want a floating-point array (because it finds
the None object it's guessing incorrectly you want an "object" array.
asarray(x, dtype=float)
array([[ 1. , nan],
[ 2. , 3. ]])
-Travis
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/numpy-discussion