Search in sources :

Example 16 with StringColumn

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

the class StringMapFunctions method padStart.

default StringColumn padStart(int minLength, char padChar) {
    StringColumn newColumn = StringColumn.create(name() + "[pad]");
    for (int r = 0; r < size(); r++) {
        String value = getString(r);
        newColumn.append(Strings.padStart(value, minLength, padChar));
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn)

Example 17 with StringColumn

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

the class StringMapFunctions method substring.

/**
 * Returns a column containing the substrings from start to the end of the input
 *
 * @throws java.lang.StringIndexOutOfBoundsException if any string in the column is shorter than
 *     start
 */
default StringColumn substring(int start) {
    StringColumn newColumn = StringColumn.create(name() + "[sub]");
    for (int r = 0; r < size(); r++) {
        String value = getString(r);
        newColumn.append(value.substring(start));
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn)

Example 18 with StringColumn

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

the class StringMapFunctions method commonPrefix.

default StringColumn commonPrefix(Column<String> column2) {
    StringColumn newColumn = StringColumn.create(name() + column2.name() + "[prefix]");
    for (int r = 0; r < size(); r++) {
        String value1 = getString(r);
        String value2 = column2.getString(r);
        newColumn.append(Strings.commonPrefix(value1, value2));
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn)

Example 19 with StringColumn

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

the class StringMapFunctions method abbreviate.

/**
 * Abbreviates a String using ellipses. This will turn "Now is the time for all good men" into
 * "Now is the time for..."
 *
 * @param maxWidth the maximum width of the resulting strings, including the elipses.
 */
default StringColumn abbreviate(int maxWidth) {
    final String defaultAbbrevMarker = "...";
    StringColumn newColumn = StringColumn.create(name() + "[abbr]");
    for (int r = 0; r < size(); r++) {
        String value = getString(r);
        newColumn.append(StringUtils.abbreviate(value, defaultAbbrevMarker, maxWidth));
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn)

Example 20 with StringColumn

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

the class Stats method asTable.

public Table asTable() {
    Table t = Table.create(name);
    StringColumn measure = StringColumn.create("Measure");
    DoubleColumn value = DoubleColumn.create("Value");
    t.addColumns(measure);
    t.addColumns(value);
    measure.append("Count");
    value.append(n);
    measure.append("sum");
    value.append(sum());
    measure.append("Mean");
    value.append(mean());
    measure.append("Min");
    value.append(min());
    measure.append("Max");
    value.append(max());
    measure.append("Range");
    value.append(range());
    measure.append("Variance");
    value.append(variance());
    measure.append("Std. Dev");
    value.append(standardDeviation());
    return t;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn) Table(tech.tablesaw.api.Table) DoubleColumn(tech.tablesaw.api.DoubleColumn)

Aggregations

StringColumn (tech.tablesaw.api.StringColumn)39 Table (tech.tablesaw.api.Table)10 DoubleColumn (tech.tablesaw.api.DoubleColumn)5 Splitter (com.google.common.base.Splitter)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 IntColumn (tech.tablesaw.api.IntColumn)4 TreeBasedTable (com.google.common.collect.TreeBasedTable)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Byte2IntMap (it.unimi.dsi.fastutil.bytes.Byte2IntMap)1 Byte2IntOpenHashMap (it.unimi.dsi.fastutil.bytes.Byte2IntOpenHashMap)1 Byte2ObjectMap (it.unimi.dsi.fastutil.bytes.Byte2ObjectMap)1 Byte2ObjectOpenHashMap (it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap)1 Int2IntMap (it.unimi.dsi.fastutil.ints.Int2IntMap)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1 Int2ObjectMap (it.unimi.dsi.fastutil.ints.Int2ObjectMap)1 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 Object2ByteOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ByteOpenHashMap)1 Object2IntOpenHashMap (it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap)1 Object2ShortOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ShortOpenHashMap)1