from numpy import array, nan
def None2NaN(x):
"""Converts None objects to nan, for use in
NumPy arrays. Returns an array."""
newlist = []
for i in x:
if i is not None:
newlist.append(i)
else:
newlist.append(nan)
return array(newlist)
Tags: arrays, nan, none
Filed under NumPy, Python.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.