How to save a list as numpy array in python?

前端 未结 9 927
心在旅途
心在旅途 2020-12-04 08:27

Is possible to construct a NumPy array from a python list?

9条回答
  •  误落风尘
    2020-12-04 09:08

    Here is a more complete example:

    import csv
    import numpy as np
    
    with open('filename','rb') as csvfile:
         cdl = list( csv.reader(csvfile,delimiter='\t'))
         print "Number of records = " + str(len(cdl))
    
    #then later
    
    npcdl = np.array(cdl)
    

    Hope this helps!!

提交回复
热议问题