set_printoptions(precision=None, threshold=None, **kwarg)

Set printing options.

These options determine the way floating point numbers and arrays are displayed.

  • precision (int or None, optional) – Number of digits of precision for floating point output (default 8). May be None if floatmode is not fixed, to print as many digits as necessary to uniquely specify the value.

  • threshold (int, optional) – Total number of array elements which trigger summarization rather than full repr (default 1000).


Floating point precision can be set:

>>> np.set_printoptions(precision=4)
>>> print(np.array([1.123456789]))
[ 1.1235]

Long arrays can be summarised:

>>> np.set_printoptions(threshold=5)
>>> print(np.arange(10))
[0. 1. 2. ... 7. 8. 9.]