I\'m curious, whether there is any way to print formatted numpy.arrays
, e.g., in a way similar to this:
x = 1.23456
print \'%.3f\' % x
>
Was surprised to not see around
method mentioned - means no messing with print options.
import numpy as np
x = np.random.random([5,5])
print(np.around(x,decimals=3))
Output:
[[0.475 0.239 0.183 0.991 0.171]
[0.231 0.188 0.235 0.335 0.049]
[0.87 0.212 0.219 0.9 0.3 ]
[0.628 0.791 0.409 0.5 0.319]
[0.614 0.84 0.812 0.4 0.307]]