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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations