Search in sources :

Example 6 with DoubleColumn

use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.

the class NumberMapFunctions method subtract.

default DoubleColumn subtract(Number value) {
    double val = value.doubleValue();
    DoubleColumn result = DoubleColumn.create(name() + " - " + val, size());
    for (int i = 0; i < size(); i++) {
        result.set(i, subtract(getDouble(i), val));
    }
    return result;
}
Also used : DoubleColumn(tech.tablesaw.api.DoubleColumn)

Example 7 with DoubleColumn

use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.

the class NumberMapFunctions method cumSum.

/**
 * Returns a new column with a cumulative sum calculated
 */
default DoubleColumn cumSum() {
    double total = 0.0;
    DoubleColumn newColumn = DoubleColumn.create(name() + "[cumSum]", size());
    for (int i = 0; i < size(); i++) {
        double value = getDouble(i);
        if (!DoubleColumnType.valueIsMissing(value)) {
            total += value;
        }
        newColumn.set(i, total);
    }
    return newColumn;
}
Also used : DoubleColumn(tech.tablesaw.api.DoubleColumn)

Example 8 with DoubleColumn

use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.

the class StringMapFunctions method countTokens.

default DoubleColumn countTokens(String separator) {
    DoubleColumn newColumn = DoubleColumn.create(name() + "[token count]", this.size());
    for (int r = 0; r < size(); r++) {
        String value = getString(r);
        Splitter splitter = Splitter.on(separator);
        splitter = splitter.trimResults();
        splitter = splitter.omitEmptyStrings();
        List<String> tokens = new ArrayList<>(splitter.splitToList(value));
        newColumn.set(r, tokens.size());
    }
    return newColumn;
}
Also used : DoubleColumn(tech.tablesaw.api.DoubleColumn) Splitter(com.google.common.base.Splitter) ArrayList(java.util.ArrayList)

Example 9 with DoubleColumn

use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.

the class StringMapFunctions method distance.

/**
 * Returns a column containing the levenshtein distance between the two given string columns
 */
default DoubleColumn distance(Column<String> column2) {
    DoubleColumn newColumn = DoubleColumn.create(name() + column2.name() + "[distance]");
    for (int r = 0; r < size(); r++) {
        String value1 = getString(r);
        String value2 = column2.getString(r);
        newColumn.append(LevenshteinDistance.getDefaultInstance().apply(value1, value2));
    }
    return newColumn;
}
Also used : DoubleColumn(tech.tablesaw.api.DoubleColumn)

Example 10 with DoubleColumn

use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.

the class NumberMapFunctions method multiply.

default DoubleColumn multiply(Number value) {
    double val = value.doubleValue();
    DoubleColumn result = DoubleColumn.create(name() + " * " + val, size());
    for (int i = 0; i < size(); i++) {
        result.set(i, multiply(getDouble(i), val));
    }
    return result;
}
Also used : DoubleColumn(tech.tablesaw.api.DoubleColumn)

Aggregations

DoubleColumn (tech.tablesaw.api.DoubleColumn)32 Table (tech.tablesaw.api.Table)7 StringColumn (tech.tablesaw.api.StringColumn)5 TreeBasedTable (com.google.common.collect.TreeBasedTable)4 IntColumn (tech.tablesaw.api.IntColumn)2 LongColumn (tech.tablesaw.api.LongColumn)2 Splitter (com.google.common.base.Splitter)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 LocalDateTime (java.time.LocalDateTime)1 UnsupportedTemporalTypeException (java.time.temporal.UnsupportedTemporalTypeException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 CellDateFormatter (org.apache.poi.ss.format.CellDateFormatter)1 CellGeneralFormatter (org.apache.poi.ss.format.CellGeneralFormatter)1 CellNumberFormatter (org.apache.poi.ss.format.CellNumberFormatter)1 CellType (org.apache.poi.ss.usermodel.CellType)1 BooleanColumn (tech.tablesaw.api.BooleanColumn)1 ColumnType (tech.tablesaw.api.ColumnType)1 FloatColumn (tech.tablesaw.api.FloatColumn)1 ShortColumn (tech.tablesaw.api.ShortColumn)1