Python - Remove a row from numpy array? -


hi wan't should simple here..i want remove row numpy array in loop like:

for in range(len(self.finalweight)):         if self.finalweight[i] >= self.cutoffoutliers:             "remove line[i self.wdata" 

i'm trying remove outliers dataset. full code os method like:

def calculate_outliers(self):     def calcweight(value):         pfinal = abs(value - self.pmed)/ self.pdev_abs_med         gradfinal = abs(gradient(value) - self.gradmed) / self.graddev_abs_med         return pfinal * gradfinal      self.pmed = median(self.wdata[:,self.ycolum-1])     self.pdev_abs_med = median(abs(self.wdata[:,self.ycolum-1] - self.pmed))     self.gradmed = median(gradient(self.wdata[:,self.ycolum-1]))     self.graddev_abs_med = median(abs(gradient(self.wdata[:,self.ycolum-1]) - self.gradmed))         self.workingdata= self.wdata[calcweight(self.wdata)<self.cutoffoutliers]      self.xdata = self.workingdata[:,self.xcolum-1]     self.ydata = self.workingdata[:,self.ycolum-1] 

i'm getting following error:

ile "bin/dmtools", line 201, in plot_gride self.calculate_outliers() file "bin/dmtools", line 188, in calculate_outliers self.workingdata= self.wdata[calcweight(self.wdata)>self.cutoffoutliers] valueerror: many indices array

there tool in numpy made mask out outliers , invalid data points: masked arrays. example linked page:

x = numpy.array([1, 2, 3, -1, 5]) mx = numpy.ma.masked_array(x, mask=[0, 0, 0, 1, 0]) print mx.mean() 

prints

2.75 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -