Search in sources :

Example 36 with StringColumn

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

the class StringMapFunctions method replaceFirst.

default StringColumn replaceFirst(String regex, String replacement) {
    StringColumn newColumn = StringColumn.create(name() + "[repl]");
    for (int r = 0; r < size(); r++) {
        String value = getString(r);
        newColumn.append(value.replaceFirst(regex, replacement));
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn)

Example 37 with StringColumn

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

the class StringMapFunctions method tokenizeAndRemoveDuplicates.

default StringColumn tokenizeAndRemoveDuplicates(String separator) {
    StringColumn newColumn = StringColumn.create(name() + "[without duplicates]", 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));
        String result = tokens.stream().distinct().collect(Collectors.joining(separator));
        newColumn.set(r, result);
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn) Splitter(com.google.common.base.Splitter) ArrayList(java.util.ArrayList)

Example 38 with StringColumn

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

the class StringMapFunctions method join.

/**
 * Return a copy of this column with the given string appended
 *
 * @param columns the column to append
 * @return the new column
 */
default StringColumn join(String separator, Column<?>... columns) {
    StringColumn newColumn = StringColumn.create(name() + "[column appended]", this.size());
    for (int r = 0; r < size(); r++) {
        StringBuilder result = new StringBuilder(getString(r));
        for (Column<?> stringColumn : columns) {
            result.append(separator).append(stringColumn.get(r));
        }
        newColumn.set(r, result.toString());
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn)

Example 39 with StringColumn

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

the class StringMapFunctions method replaceAll.

default StringColumn replaceAll(String regex, String replacement) {
    StringColumn newColumn = StringColumn.create(name() + "[repl]");
    for (int r = 0; r < size(); r++) {
        String value = getString(r);
        newColumn.append(value.replaceAll(regex, replacement));
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn)

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