def run(self, table): column = table.columns[self._column_name] data = column.values_without_nulls_sorted() m = self._median.run(table) return median(tuple(abs(n - m) for n in data))
def run(self, table): column = table.columns[self._column_name] data = column.values_without_nulls_sorted() if data: m = self._median.run(table) return median(tuple(abs(n - m) for n in data))
def run(self, column): """ :returns: :class:`decimal.Decimal`. """ if not isinstance(column.data_type, Number): raise DataTypeError( 'MAD can only be applied to columns containing Number data.') if column.aggregate(HasNulls()): warn_null_calculation(self, column) data = column.values_without_nulls_sorted() m = column.aggregate(Percentiles())[50] return median(tuple(abs(n - m) for n in data))
def run(self, table): """ :returns: :class:`decimal.Decimal`. """ column = table.columns[self._column_name] if not isinstance(column.data_type, Number): raise DataTypeError('MAD can only be applied to columns containing Number data.') has_nulls = HasNulls(self._column_name).run(table) if has_nulls: warn_null_calculation(self, column) data = column.values_without_nulls_sorted() m = Median(self._column_name).run(table) return median(tuple(abs(n - m) for n in data))