Printing numpy.float64 with full precision

前端 未结 2 1211
北荒
北荒 2020-12-29 03:49

What is the proper/accepted way to print and convert a numpy.float64 to a string? I\'ve noticed just using print or str() will lose some precision

相关标签:
2条回答
  • 2020-12-29 04:06

    The astype method works well:

    >>> numpy.float64('6374.345407799015').astype(str)
    '6374.345407799015'
    
    0 讨论(0)
  • 2020-12-29 04:19

    Look into numpy.set_printoptions. Specifically,

    numpy.set_printoptions(precision=15)
    
    0 讨论(0)
提交回复
热议问题