void TestSelectDrop()
        {
            var data = new[] { new TestClass()
                               {
                                   A = 1, B = 2, C = 3,
                               }, new TestClass()
                               {
                                   A = 4, B = 5, C = 6
                               } };
            var dataView     = ComponentCreation.CreateDataView(Env, data);
            var est          = ColumnSelectingEstimator.DropColumns(Env, "A", "C");
            var transformer  = est.Fit(dataView);
            var result       = transformer.Transform(dataView);
            var foundColumnA = result.Schema.TryGetColumnIndex("A", out int aIdx);
            var foundColumnB = result.Schema.TryGetColumnIndex("B", out int bIdx);
            var foundColumnC = result.Schema.TryGetColumnIndex("C", out int cIdx);

            Assert.False(foundColumnA);
            Assert.True(foundColumnB);
            Assert.Equal(0, bIdx);
            Assert.False(foundColumnC);
        }
Esempio n. 2
0
 /// <summary>
 /// DropColumns is used to select a list of columns that user wants to drop from a given input. Any column not specified will
 /// be maintained in the output schema.
 /// </summary>
 /// <param name="catalog">The transform's catalog.</param>
 /// <param name="columnsToDrop">The array of column names to drop.</param>
 public static ColumnSelectingEstimator DropColumns(this TransformsCatalog catalog, params string[] columnsToDrop)
 => ColumnSelectingEstimator.DropColumns(CatalogUtils.GetEnvironment(catalog), columnsToDrop);