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
>
I often want different columns to have different formats. Here is how I print a simple 2D array using some variety in the formatting by converting (slices of) my NumPy array to a tuple:
import numpy as np
dat = np.random.random((10,11))*100 # Array of random values between 0 and 100
print(dat) # Lines get truncated and are hard to read
for i in range(10):
print((4*"%6.2f"+7*"%9.4f") % tuple(dat[i,:]))