Revist - 1 year ago 66

Python Question

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.