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
I got quite frustrated after scouring the internet and not finding an answer for this, so I wrote my own piece of code. Hope this is what you're looking for
import numpy as np
from numpy import ma
exp = np.floor(ma.log10(abs(X)).filled(0))
ans = np.round(X*10**-exp, sigfigs-1) * 10**exp
Just plug in your np array X and the required number of significant figures. Cheers!