Saving arrays as columns with np.savetxt

后端 未结 4 1847
Happy的楠姐
Happy的楠姐 2021-01-29 22:16

I am trying to do something that is probable very simple. I would like to save three arrays to a file as columns using \'np.savetxt\' When I try this

x = [1,2,3         


        
4条回答
  •  梦如初夏
    2021-01-29 22:37

    Use numpy.transpose():

    np.savetxt('myfile.txt', np.transpose([x,y,z]))
    

    I find this more intuitive than using np.c_[].

提交回复
热议问题