def test_all_missing(self): index = ["bla", "blue", "blo"] values0 = [np.nan, np.nan, np.nan] values1 = [0.4, np.nan, 0.8] values2 = [0.3, 0.0, np.nan] util.mean_impute_frame(self.make_input(index, [values0, values1, values2]))
def test_all_missing(self): index = ["bla", "blue", "blo"] values0 = [np.nan, np.nan, np.nan] values1 = [0.4, np.nan, 0.8] values2 = [0.3, 0.0, np.nan] util.mean_impute_frame( self.make_input(index, [values0, values1, values2]))
def test_impute_three_series(self): index = ["bla", "blue", "blo"] values0 = [np.nan, 0.4, np.nan] values1 = [0.4, np.nan, 0.8] values2 = [0.3, 0.0, np.nan] expected0 = [0.4, 0.4, 0.4], [1, 0, 1] expected1 = [0.4, 0.6, 0.8], [0, 1, 0] expected2 = [0.3, 0.0, 0.15], [0, 0, 1] expected = self.make_expected(index, [expected0, expected1, expected2]) actual = util.mean_impute_frame(self.make_input(index, [values0, values1, values2])) assert_frame_equal(expected, actual)
def test_no_impute(self): index = ["bla", "blue", "blo"] values0 = [0.2, 0.4, 0.4] values1 = [0.4, 0.8, 0.8] values2 = [0.3, 0.0, 0.8] expected0 = values0, [0, 0, 0] expected1 = values1, [0, 0, 0] expected2 = values2, [0, 0, 0] expected = self.make_expected(index, [expected0, expected1, expected2]) actual = util.mean_impute_frame(self.make_input(index, [values0, values1, values2])) assert_frame_equal(expected, actual)
def test_impute_three_series(self): index = ["bla", "blue", "blo"] values0 = [np.nan, 0.4, np.nan] values1 = [0.4, np.nan, 0.8] values2 = [0.3, 0.0, np.nan] expected0 = [0.4, 0.4, 0.4], [1, 0, 1] expected1 = [0.4, 0.6, 0.8], [0, 1, 0] expected2 = [0.3, 0.0, 0.15], [0, 0, 1] expected = self.make_expected(index, [expected0, expected1, expected2]) actual = util.mean_impute_frame( self.make_input(index, [values0, values1, values2])) assert_frame_equal(expected, actual)
def test_no_impute(self): index = ["bla", "blue", "blo"] values0 = [0.2, 0.4, 0.4] values1 = [0.4, 0.8, 0.8] values2 = [0.3, 0.0, 0.8] expected0 = values0, [0, 0, 0] expected1 = values1, [0, 0, 0] expected2 = values2, [0, 0, 0] expected = self.make_expected(index, [expected0, expected1, expected2]) actual = util.mean_impute_frame( self.make_input(index, [values0, values1, values2])) assert_frame_equal(expected, actual)
def test_all_missing_not_in_subset(self): index = ["bla", "blue", "blo"] values0 = [np.nan, np.nan, np.nan] values1 = [0.4, np.nan, 0.8] values2 = [0.3, 0.0, np.nan] subset = ["original2"] expected0 = values0, None expected1 = values1, None expected2 = [0.3, 0.0, 0.15], [0, 0, 1] expected = self.make_expected(index, [expected0, expected1, expected2]) actual = util.mean_impute_frame(self.make_input(index, [values0, values1, values2]), subset=subset) assert_frame_equal(expected, actual)
def test_impute_empty_subset(self): index = ["bla", "blue", "blo"] values0 = [np.nan, 0.4, np.nan] values1 = [0.4, np.nan, 0.8] values2 = [0.3, 0.0, np.nan] subset = [] expected0 = values0, None expected1 = values1, None expected2 = values2, None expected = self.make_expected(index, [expected0, expected1, expected2]) actual = util.mean_impute_frame(self.make_input(index, [values0, values1, values2]), subset=subset) assert_frame_equal(expected, actual)
def test_all_missing_not_in_subset(self): index = ["bla", "blue", "blo"] values0 = [np.nan, np.nan, np.nan] values1 = [0.4, np.nan, 0.8] values2 = [0.3, 0.0, np.nan] subset = ["original2"] expected0 = values0, None expected1 = values1, None expected2 = [0.3, 0.0, 0.15], [0, 0, 1] expected = self.make_expected(index, [expected0, expected1, expected2]) actual = util.mean_impute_frame(self.make_input( index, [values0, values1, values2]), subset=subset) assert_frame_equal(expected, actual)
def test_impute_empty_subset(self): index = ["bla", "blue", "blo"] values0 = [np.nan, 0.4, np.nan] values1 = [0.4, np.nan, 0.8] values2 = [0.3, 0.0, np.nan] subset = [] expected0 = values0, None expected1 = values1, None expected2 = values2, None expected = self.make_expected(index, [expected0, expected1, expected2]) actual = util.mean_impute_frame(self.make_input( index, [values0, values1, values2]), subset=subset) assert_frame_equal(expected, actual)