Exemple #1
0
    def test_slice_features_original_unchanged(self):
        df = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]],
                          columns=["weight", "height", "age"])
        labels = ["m", "f", "m"]
        dataset = DataSet(df, labels=labels)
        sliced = dataset.slice_features(["weight", "height"])

        # Modify sliced data
        sliced.set_column("weight", [0, 0, 0])
        sliced.labels[0] = "x"

        # Check that it was indeed changed
        assert_that(sliced.get_column("weight"), contains(0, 0, 0))
        assert_that(sliced.get_labels(), contains("x", "f", "m"))

        # Verify it was not changed in the original dataset
        assert_that(dataset.get_column("weight"), contains(1, 4, 7))
        assert_that(dataset.get_labels(), contains(*labels))
Exemple #2
0
 def test_get_column(self):
     dataset = DataSet([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     column1 = dataset.get_column(1)
     assert_that(column1.values, contains(2, 5, 8))
Exemple #3
0
 def test_get_column_set_value(self):
     dataset = DataSet([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     dataset.get_column(1)[:] = 1
     assert_that(dataset.get_column(1), contains(1, 1, 1))