Search in sources :

Example 11 with StringColumn

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

the class StringMapFunctions method lowerCase.

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

Example 12 with StringColumn

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

the class StringMapFunctions method replaceAll.

/**
 * Creates a new column, replacing each string in this column with a new string formed by
 * replacing any substring that matches the regex
 *
 * @param regexArray the regex array to replace
 * @param replacement the replacement array
 * @return the new column
 */
default StringColumn replaceAll(String[] regexArray, String replacement) {
    StringColumn newColumn = StringColumn.create(name() + "[repl]", this.size());
    for (int r = 0; r < size(); r++) {
        String value = getString(r);
        for (String regex : regexArray) {
            value = value.replaceAll(regex, replacement);
        }
        newColumn.set(r, value);
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn)

Example 13 with StringColumn

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

the class StringMapFunctions method trim.

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

Example 14 with StringColumn

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

the class StringMapFunctions method padEnd.

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

Example 15 with StringColumn

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

the class StringMapFunctions method tokenizeAndSort.

/**
 * Splits on Whitespace and returns the lexicographically sorted result.
 *
 * @return a {@link StringColumn}
 */
default StringColumn tokenizeAndSort() {
    StringColumn newColumn = StringColumn.create(name() + "[sorted]", this.size());
    for (int r = 0; r < size(); r++) {
        String value = getString(r);
        Splitter splitter = Splitter.on(CharMatcher.whitespace());
        splitter = splitter.trimResults();
        splitter = splitter.omitEmptyStrings();
        List<String> tokens = new ArrayList<>(splitter.splitToList(value));
        Collections.sort(tokens);
        value = String.join(" ", tokens);
        newColumn.set(r, value);
    }
    return newColumn;
}
Also used : StringColumn(tech.tablesaw.api.StringColumn) Splitter(com.google.common.base.Splitter) ArrayList(java.util.ArrayList)

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