I want to print floats with precision 4. I use numpy , jupyter notebook I tried:
%precision %.4g
%precision 2
np.set_printoptions(precision=2)
print(0.6776776)
the output:
0.6776776
Any Ideas what is wrong ?
# Name                    Version                   
ipython                   6.4.0                    
ipython_genutils          0.2.0            
msgpack-python            0.5.6            
python                    3.6.5                
python-dateutil           2.7.3       
                Print does not care about numpy or IPython formatters. It calls str() in the Background, any formatting has to be done using Standard print formatters (%.2f and the like). Look at the different Output for:
%precision 3
a = 0.6776776
print(a)
a
The result will be:
0.6776776
0.678
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With