Show an array in format of scientific notation

后端 未结 2 1098
别跟我提以往
别跟我提以往 2021-02-05 18:41

I would like to show my results in scientific notation (e.g., 1.2e3). My data is in array format. Is there a function like tolist() that can convert the array to fl

2条回答
  •  感动是毒
    2021-02-05 19:08

    You can format each of the elements of an array in scientific notation and then display them as you'd like. Lists cannot be converted to floats, they have floats inside them potentially.

    import numpy as np
    a = np.zeroes(shape=(5, 5), dtype=float)
    for e in a.flat:
        print "%E" % e
    

    or

    print ["%E" % e for e in a.flat]
    

提交回复
热议问题