Python numpy.savetxt() saves multidimensional array

2021-12-28
#Python

1. numpy.column_stack() for column

import numpy

a = np.array([1,2,3,4])
b = np.array([5,6,7,8])
c = np.array([9,10,11,12])
numpy.savetxt('filename.txt', numpy.column_stack((a,b,c)))

2. np.row_stack() for row

import numpy

a = np.array([1,2,3,4])
b = np.array([5,6,7,8])
c = np.array([9,10,11,12])
numpy.savetxt('filename.txt', numpy.row_stack((a,b,c)))

3. Reference