Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get numpy not to print in scientific notation [duplicate]

Tags:

python

numpy

This is a very simple question but I don't know the right words to Google. I have a numpy array:

A = np.array([ 8.1588e-01, -3.9675e-04])

And I would like to print it as normal decimal numbers. That is 0.81588, -0.00039675.

How can you do that?

like image 682
graffe Avatar asked Sep 19 '25 13:09

graffe


1 Answers

Numpy let's you customize the output globally using set_printoptions.

To get rid of scientific notation, you can use:

 np.set_printoptions(suppress=True) # don't use scientific notation

From the documentation:

suppress : bool, optional

If True, always print floating point numbers using fixed point notation, in which case numbers equal to zero in the current precision will print as zero. If False, then scientific notation is used when absolute value of the smallest number is < 1e-4 or the ratio of the maximum absolute value to the minimum is > 1e3. The default is False.

like image 84
Derlin Avatar answered Sep 21 '25 04:09

Derlin