Revist Revist - 1 year ago 87
Python Question

Converting an array of floats to an array of strings in scientific notation

I want to convert the array created by numpy.linspace(1,10,1) to an array od strings in a scientific notation. How to do this?

Answer Source

You can iterate over the elements of the array, and convert them to strings one by one:

array = numpy.linspace(1, 10, 1)
["%e" % x for x in array]

Here %e renders the number in scientific notation. You can also use %f for a notation with decimal point, or %g for auto-choice between different representations.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download