Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How can i convert an array like this:

[ 76809102.22  38393173.33    -17066.67 -48000000.           0.           0.   -28809102.22 -38393173.33    -17066.67]

to exponential?

[  7.68091022e+07   3.83931733e+07  -1.70666700e+04  -4.80000000e+07   0.00000000e+00   0.00000000e+00  -2.88091022e+07  -3.83931733e+07  -1.70666700e+04]

I have been trying many thing and just get error!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
175 views
Welcome To Ask or Share your Answers For Others

1 Answer

If x is a NumPy array, then you could use

np.set_printoptions(formatter={'float': '{: 0.8e}'.format})

to change the way floats are displayed:

import numpy as np

x = np.array([76809102.22, 38393173.33, -17066.67, -48000000., 0., 0., -28809102.22, 
              -38393173.33, -17066.67])
np.set_printoptions(formatter={'float': '{: 0.8e}'.format})
print(x)

yields

[ 7.68091022e+07  3.83931733e+07 -1.70666700e+04 -4.80000000e+07
  0.00000000e+00  0.00000000e+00 -2.88091022e+07 -3.83931733e+07
 -1.70666700e+04]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...