def test_get_deviation__Series(self): result = calculator.get_deviations(pd.Series([1.2, 3, 4.8])) self.assertFrameEqual(result, pd.Series([-1, 0, 1]), check_dtype=False)
def test_get_deviation__DataFrame(self): result = calculator.get_deviations(pd.DataFrame({'a': [1, 3, 5], 'b': [5, 3, 1]})) self.assertFrameEqual(result, pd.DataFrame({'a': [-1, 0, 1], 'b': [1, 0, -1]}), check_dtype=False)
def is_outlier(frame, tolerance): """ Tests whether each value of <frame> deviates from the mean of the column by more than <tolerance> * sigma frame: Series or DataFrame object """ return np.abs(get_deviations(frame)) > tolerance