Dumping numpy array into an excel file

前端 未结 2 1213
感动是毒
感动是毒 2021-01-04 20:56

I am trying to dump numpy array into an excel file using savetxt method, but I am getting this weird error on the console:

.18e,%.18e,%.18e,%.18e,%.18e,%.18e         


        
2条回答
  •  梦谈多话
    2021-01-04 21:48

    Bit late, but might help others facing such an issue.

    This error is because you appear to have set

    dtype = np.ndarray

    when creating / defining your Numpy matrix first_layer_output.

    One solution to this problem is modifying your command storing the

    np.savetxt('test.csv', first_layer_output, delimiter=',', fmt='%s')
    

    This command now outputs the contents of the array as a string, irrespective the actual data types being used. Hope this helps.

提交回复
热议问题