Search in sources :

Example 41 with Selection

use of tech.tablesaw.selection.Selection in project symja_android_library by axkr.

the class Table method dropWhere.

public Table dropWhere(Selection selection) {
    Selection opposite = new BitmapBackedSelection();
    opposite.addRange(0, rowCount());
    opposite.andNot(selection);
    Table newTable = this.emptyCopy(opposite.size());
    Rows.copyRowsToTable(opposite, this, newTable);
    return newTable;
}
Also used : PivotTable(tech.tablesaw.aggregate.PivotTable) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection) Selection(tech.tablesaw.selection.Selection) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection)

Example 42 with Selection

use of tech.tablesaw.selection.Selection in project symja_android_library by axkr.

the class Table method dropRows.

public Table dropRows(int... rowNumbers) {
    Preconditions.checkArgument(Ints.max(rowNumbers) <= rowCount());
    Selection selection = Selection.withRange(0, rowCount()).andNot(Selection.with(rowNumbers));
    return where(selection);
}
Also used : BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection) Selection(tech.tablesaw.selection.Selection)

Example 43 with Selection

use of tech.tablesaw.selection.Selection in project symja_android_library by axkr.

the class Table method sampleSplit.

/**
 * Splits the table into two, randomly assigning records to each according to the proportion given
 * in trainingProportion
 *
 * @param table1Proportion The proportion to go in the first table
 * @return An array two tables, with the first table having the proportion specified in the method
 *     parameter, and the second table having the balance of the rows
 */
public Table[] sampleSplit(double table1Proportion) {
    Table[] tables = new Table[2];
    int table1Count = (int) Math.round(rowCount() * table1Proportion);
    Selection table2Selection = new BitmapBackedSelection();
    for (int i = 0; i < rowCount(); i++) {
        table2Selection.add(i);
    }
    Selection table1Selection = new BitmapBackedSelection();
    Selection table1Records = selectNRowsAtRandom(table1Count, rowCount());
    for (int table1Record : table1Records) {
        table1Selection.add(table1Record);
    }
    table2Selection.andNot(table1Selection);
    tables[0] = where(table1Selection);
    tables[1] = where(table2Selection);
    return tables;
}
Also used : PivotTable(tech.tablesaw.aggregate.PivotTable) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection) Selection(tech.tablesaw.selection.Selection) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection)

Example 44 with Selection

use of tech.tablesaw.selection.Selection in project symja_android_library by axkr.

the class Table method dropRowsWithMissingValues.

/**
 * Returns only those records in this table that have no columns with missing values
 */
public Table dropRowsWithMissingValues() {
    Selection missing = new BitmapBackedSelection();
    for (int row = 0; row < rowCount(); row++) {
        for (int col = 0; col < columnCount(); col++) {
            Column<?> c = column(col);
            if (c.isMissing(row)) {
                missing.add(row);
                break;
            }
        }
    }
    Selection notMissing = Selection.withRange(0, rowCount());
    notMissing.andNot(missing);
    Table temp = emptyCopy(notMissing.size());
    Rows.copyRowsToTable(notMissing, this, temp);
    return temp;
}
Also used : PivotTable(tech.tablesaw.aggregate.PivotTable) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection) Selection(tech.tablesaw.selection.Selection) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection)

Example 45 with Selection

use of tech.tablesaw.selection.Selection in project symja_android_library by axkr.

the class ExprColumn method isIn.

public Selection isIn(Collection<IExpr> strings) {
    Set<IExpr> stringSet = Sets.newHashSet(strings);
    Selection results = new BitmapBackedSelection();
    for (int i = 0; i < size(); i++) {
        if (stringSet.contains(values.get(i))) {
            results.add(i);
        }
    }
    return results;
}
Also used : BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection) Selection(tech.tablesaw.selection.Selection) IExpr(org.matheclipse.core.interfaces.IExpr) BitmapBackedSelection(tech.tablesaw.selection.BitmapBackedSelection)

Aggregations

Selection (tech.tablesaw.selection.Selection)85 BitmapBackedSelection (tech.tablesaw.selection.BitmapBackedSelection)80 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)31 PivotTable (tech.tablesaw.aggregate.PivotTable)3 BooleanColumn (tech.tablesaw.api.BooleanColumn)3 ByteOpenHashSet (it.unimi.dsi.fastutil.bytes.ByteOpenHashSet)2 IntIterator (it.unimi.dsi.fastutil.ints.IntIterator)2 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)2 ShortOpenHashSet (it.unimi.dsi.fastutil.shorts.ShortOpenHashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IExpr (org.matheclipse.core.interfaces.IExpr)2 ByteArrayList (it.unimi.dsi.fastutil.bytes.ByteArrayList)1 ByteIterator (it.unimi.dsi.fastutil.bytes.ByteIterator)1 IntRBTreeSet (it.unimi.dsi.fastutil.ints.IntRBTreeSet)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 CategoricalColumn (tech.tablesaw.api.CategoricalColumn)1 DoubleColumn (tech.tablesaw.api.DoubleColumn)1 Column (tech.tablesaw.columns.Column)1