or as a string ('{:.2f} %'*len(x)).format(*x) yields '1.23 %2.35 %3.46 %' repeats the format string by the size of x, then starred x unravels to format.
The .format mechanism depends on what's been defined in the object's __format__ method. numpy developers haven't put much effort into expanding this beyond the basics ('!s' and '!r'). Note that your format string doesn't work for lists either.
np.set_printoptions(precision=2)worked..I was wondering though why the above code doesn't work..formatmechanism depends on what's been defined in the object's__format__method.numpydevelopers haven't put much effort into expanding this beyond the basics ('!s' and '!r'). Note that your format string doesn't work for lists either.