How can I print numpy array with 3 decimal places? I tried array.round(3)
but it keeps printing like this 6.000e-01
. Is there an option to make it print like this: 6.000
?
I got one solution as print ("%0.3f" % arr)
, but I want a global solution i.e. not doing that every time I want to check the array contents.
An easier solution is to use numpy around.
This will set numpy to use this lambda function for formatting every float it prints out.
other types you can define formatting for (from the docstring of the function)
Actually what you need is
np.set_printoptions(precision=3)
. There are a lot of helpful other parameters there.For example:
will show you the following: