How to append elements to a numpy array

后端 未结 1 862
刺人心
刺人心 2021-01-11 13:57

I want to do the equivalent to adding elements in a python list recursively in Numpy, As in the following code

matrix = open(\'workfile\', \'w\')
A = []
for          


        
相关标签:
1条回答
  • 2021-01-11 14:31

    You need to pass the array, A, to Numpy.

    matrix = open('workfile', 'w')
    A = np.array([])
    for row in matrix:
        A = numpy.append(A, row)
    
    print A
    

    However, loading from the files directly is probably a nicer solution.

    0 讨论(0)
提交回复
热议问题