Skip to content Skip to sidebar Skip to footer

Can't Save A Numpy 2-d Array Into A File

I have the following 2-d numpy matrix, which was a concatenation of two matrices: >>> mnist1_train_final_data=np.hstack((y_train_mnist_ni,features_train_mnist1))

Solution 1:

S32 is a string type. The format you're specifying is for float types. To save a string type, with savetxt you need to pass the "%s" formatter. Note that the default format is not valid for string types so you must pass a valid string formatter such as "%s"

np.savetxt('test.txt', mnist1_train_final_data, delimiter=',', fmt='%s')


Post a Comment for "Can't Save A Numpy 2-d Array Into A File"