% precision does not work in certain cases in jupyter notebook

This is something i am learning using the jupyter notebook.
If i execute the magic command as follows, pi will be up to the decimal point 3.
The calculation result of numpy is a situation where the notation of the decimal point does not change.
Could you tell me how to solve it?

Source code and output
import numpy as np
from math import pi
% precision 3
'% .3f'
scores = np.array ([30, 40, 100])
std = np.sqrt (np.var (scores, ddof = 0))
np.set_printoptions (precision = 3)

I tried the above but did not improve it.


python 3.7.3
jupyter 1.0.0
numpy 1.16.4

  • Answer # 1

    There is a link from https://github.com/numpy/numpy/pull/9201#issuecomment-332609336 ↑.

    It seems similar to what is discussed in


    Whenstrorreprfunction is applied to

    numpy.float64, the result should behave in the same way as the built-in Python float type Since it seems to be based on a philosophy, I don't think there is any means (you can only format it yourself).


    I had to find out if there was a way to write numpy.float64 for jupyter.
    Please forgive me for half the answer.