I am saving some data with numpy.savetxt(path,array,fmt="%.2f %.2f %.2f %.2f %.2f")
and I want the text file to be formated nicely. I would like to limit the floats to a certain amount of digits, like this:
11.2345 -> 11.2
1.2345 -> 1.23
Currently I get:
11.2345 -> 11.23
1.2345 -> 1.23
This destroys the layout of the text file.
I know that there are a couple of similar questions on SO, however I was not able to apply any of the solutions to numpy.savetxt()
.
Try using fmt="%9.2f"
. It seems to give nice results for me:
25.72 433.54 135.69 898.93
177.46 120.65 954.13 480.82
963.45 774.35 289.08 93.64