How to force a ndarray show in normal way instead of scientific notation?

后端 未结 2 1548
难免孤独
难免孤独 2021-01-13 16:21

I\'m trying to print a ndarray on the screen. But python always shows it in scientific notation, which I don\'t like. For a scalar we can use

>>> p         


        
2条回答
  •  无人共我
    2021-01-13 16:32

    The numpy.set_string_function function can be used to change the string representation of arrays.

    You can also use numpy.set_print_options to change the precision used by default and turn off reporting of small numbers in scientific notation.

    From the examples for set_print_options:

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

提交回复
热议问题