1

When printing arrays, Numpy replaces trailing 0s with s, e.g.

[-0.678231 -0.618304 -0.6077    0.014845]

How can I fix this and make it print the 0s?

MWB
  • 10,855
  • 6
  • 41
  • 80

1 Answers1

4

You can use numpy's set_printoptions with a custom formatter to set the precision and exact format of the output; for your case,

np.set_printoptions(formatter={'float': '{: 0.3f}'.format})

should do the trick.

mgilson
  • 283,004
  • 58
  • 591
  • 667
manan
  • 1,305
  • 13
  • 23