Convert python list with None values to numpy array with nan values

后端 未结 2 408
日久生厌
日久生厌 2021-02-01 16:07

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

2条回答
  •  清酒与你
    2021-02-01 16:25

    What about

    my_array = np.array(map(lambda x: numpy.nan if x==None else x, my_list))
    

提交回复
热议问题