use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.
the class NumberMapFunctions method divide.
default DoubleColumn divide(NumericColumn<?> column2) {
int col1Size = size();
int col2Size = column2.size();
if (col1Size != col2Size)
throw new IllegalArgumentException("The columns must have the same number of elements");
DoubleColumn result = DoubleColumn.create(name() + " / " + column2.name(), col1Size);
for (int r = 0; r < col1Size; r++) {
result.set(r, divide(getDouble(r), column2.getDouble(r)));
}
return result;
}
use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.
the class NumberMapFunctions method cumMin.
/**
* Returns a new column with a cumulative maximum calculated
*/
default DoubleColumn cumMin() {
double min = DoubleColumnType.missingValueIndicator();
DoubleColumn newColumn = DoubleColumn.create(name() + "[cumMin]", size());
for (int i = 0; i < size(); i++) {
double value = getDouble(i);
if (!DoubleColumnType.valueIsMissing(value)) {
min = DoubleColumnType.valueIsMissing(min) ? value : Math.min(min, value);
}
newColumn.set(i, min);
}
return newColumn;
}
use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.
the class NumberMapFunctions method remainder.
default DoubleColumn remainder(DoubleColumn column2) {
DoubleColumn result = DoubleColumn.create(name() + " % " + column2.name(), size());
for (int r = 0; r < size(); r++) {
double val1 = getDouble(r);
double val2 = column2.getDouble(r);
if (DoubleColumnType.valueIsMissing(val1) || DoubleColumnType.valueIsMissing(val2)) {
result.setMissing(r);
} else {
result.set(r, getDouble(r) % column2.getDouble(r));
}
}
return result;
}
use of tech.tablesaw.api.DoubleColumn 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;
}
use of tech.tablesaw.api.DoubleColumn in project symja_android_library by axkr.
the class SqlResultSetReader method read.
/**
* Returns a new table with the given tableName, constructed from the given result set
*
* @throws SQLException if there is a problem detected in the database
*/
public static Table read(ResultSet resultSet) throws SQLException {
ResultSetMetaData metaData = resultSet.getMetaData();
Table table = Table.create();
// Setup the columns and add to the table
for (int i = 1; i <= metaData.getColumnCount(); i++) {
ColumnType type = getColumnType(metaData.getColumnType(i), metaData.getScale(i), metaData.getPrecision(i));
Preconditions.checkState(type != null, "No column type found for %s as specified for column %s", metaData.getColumnType(i), metaData.getColumnName(i));
Column<?> newColumn = type.create(metaData.getColumnLabel(i));
table.addColumns(newColumn);
}
// Add the rows
while (resultSet.next()) {
for (int i = 1; i <= metaData.getColumnCount(); i++) {
Column<?> column = // subtract 1 because results sets originate at 1 not 0
table.column(i - 1);
if (column instanceof ShortColumn) {
appendToColumn(column, resultSet, resultSet.getShort(i));
} else if (column instanceof IntColumn) {
appendToColumn(column, resultSet, resultSet.getInt(i));
} else if (column instanceof LongColumn) {
appendToColumn(column, resultSet, resultSet.getLong(i));
} else if (column instanceof FloatColumn) {
appendToColumn(column, resultSet, resultSet.getFloat(i));
} else if (column instanceof DoubleColumn) {
appendToColumn(column, resultSet, resultSet.getDouble(i));
} else if (column instanceof BooleanColumn) {
appendToColumn(column, resultSet, resultSet.getBoolean(i));
} else {
column.appendObj(resultSet.getObject(i));
}
}
}
return table;
}
Aggregations