2

The command format short in Matlab makes all the print outs in the command window be "Short, fixed-decimal format with 4 digits after the decimal point."

I know there is np.round, but I would like to have this functionality that Matlab offers in python so I dont have to write round every time. This in order to get a better overview of arrays/dataframes when they are printed.

I am interested in automatic rounding of numbers/floats printed in the terminal without using np.round

Ideally I would like also to be able to choose the number of digits (4).

Thanks

1 Answers1

1

You can use numpy.set_printoptions, from the documentation:

np.set_printoptions(precision=4)
np.array([1.123456789])
[1.1235]
rinkert
  • 6,593
  • 2
  • 12
  • 31