Dump a NumPy array into a csv file

前端 未结 10 1130

Is there a way to dump a NumPy array into a CSV file? I have a 2D NumPy array and need to dump it in human-readable format.

10条回答
  •  长发绾君心
    2020-11-22 13:08

    numpy.savetxt saves an array to a text file.

    import numpy
    a = numpy.asarray([ [1,2,3], [4,5,6], [7,8,9] ])
    numpy.savetxt("foo.csv", a, delimiter=",")
    

提交回复
热议问题