I\'ve tried searching this and can\'t find a satisfactory answer.
I want to take a list/array of numbers and round them all to n significant figures. I have written
Is numpy.set_printoptions what you're looking for?
import numpy as np
np.set_printoptions(precision=2)
print np.array([ 0.0, -1.2366e22, 1.2544444e-15, 0.001222 ])
Gives:
[ 0.00e+00 -1.24e+22 1.25e-15 1.22e-03]
Edit:
numpy.around appears to solve aspects of this problem if you're trying to transform the data. However, it doesn't do what you want in cases where the exponent is negative.