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
  • 11,740
  • 6
  • 46
  • 91

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
  • 300,191
  • 65
  • 633
  • 696
manan
  • 1,385
  • 13
  • 23