I am trying to convert a list that contains numeric values and None values to numpy.array, such that None is replaces with numpy.nan
None
numpy.array
numpy.nan
You simply have to explicitly declare the data type:
>>> my_list = [3, 5, 6, None, 6, None] >>> np.array(my_list, dtype=np.float) array([ 3., 5., 6., nan, 6., nan])