savetxt How change the type from float64 to int or double
You can define how the output has to be formatted with the fmt
parameter of np.savetxt
, e.g.:
for floats rounded to five decimals:
np.savetxt("file.txt", output, fmt='%10.5f', delimiter='\t')
for integers:
np.savetxt("file.txt", output, fmt='%i', delimiter='\t')
Here you can find more information about the possibilities of fmt
:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.savetxt.html
In case you want to specify the number of decimals in the float the
np.savetxt("file.txt", output, fmt='%10.5f', delimiter='\t')
7 decimals in this case
np.savetxt("file.txt", output, fmt='%10.7f', delimiter='\t')
Basically, fmt = %10.Yf' where Y specifies the number of decs.