use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class DateTimeMapFunctions method yearWeek.
/**
* Returns a StringColumn with the year and week-of-year derived from this column concatenated
* into a String that will sort lexicographically in temporal order.
*
* <p>This simplifies the production of plots and tables that aggregate values into standard
* temporal units (e.g., you want monthly data but your source data is more than a year long and
* you don't want months from different years aggregated together).
*/
default StringColumn yearWeek() {
StringColumn newColumn = StringColumn.create(this.name() + " year & week");
for (int r = 0; r < this.size(); r++) {
long c1 = this.getLongInternal(r);
if (DateTimeColumn.valueIsMissing(c1)) {
newColumn.append(StringColumnType.missingValueIndicator());
} else {
String ym = String.valueOf(getYear(c1));
ym = ym + "-" + Strings.padStart(String.valueOf(getWeekOfYear(c1)), 2, '0');
newColumn.append(ym);
}
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class DateTimeMapFunctions method yearDay.
/**
* Returns a StringColumn with the year and day-of-year derived from this column concatenated into
* a String that will sort lexicographically in temporal order.
*
* <p>This simplifies the production of plots and tables that aggregate values into standard
* temporal units (e.g., you want monthly data but your source data is more than a year long and
* you don't want months from different years aggregated together).
*/
default StringColumn yearDay() {
StringColumn newColumn = StringColumn.create(this.name() + " year & month");
for (int r = 0; r < this.size(); r++) {
long c1 = this.getLongInternal(r);
if (DateTimeColumn.valueIsMissing(c1)) {
newColumn.append(StringColumnType.missingValueIndicator());
} else {
String ym = String.valueOf(getYear(c1));
ym = ym + "-" + Strings.padStart(String.valueOf(getDayOfYear(c1)), 3, '0');
newColumn.append(ym);
}
}
return newColumn;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class ByteDictionaryMap method countByCategory.
/**
*/
@Override
public Table countByCategory(String columnName) {
Table t = Table.create("Column: " + columnName);
StringColumn categories = StringColumn.create("Category");
IntColumn counts = IntColumn.create("Count");
// Now uses the keyToCount map
for (Map.Entry<Byte, Integer> entry : keyToCount.byte2IntEntrySet()) {
categories.append(getValueForKey(entry.getKey()));
counts.append(entry.getValue());
}
t.addColumns(categories);
t.addColumns(counts);
return t;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class IntDictionaryMap method countByCategory.
/**
*/
@Override
public Table countByCategory(String columnName) {
Table t = Table.create("Column: " + columnName);
StringColumn categories = StringColumn.create("Category");
IntColumn counts = IntColumn.create("Count");
// Now uses the keyToCount map
for (Map.Entry<Integer, Integer> entry : keyToCount.int2IntEntrySet()) {
categories.append(getValueForKey(entry.getKey()));
counts.append(entry.getValue());
}
t.addColumns(categories);
t.addColumns(counts);
return t;
}
use of tech.tablesaw.api.StringColumn in project symja_android_library by axkr.
the class StringMapFunctions method repeat.
/**
* Repeats each the column's values elementwise, concatinating the results into a new StringColumn
*
* @param times The number of repeat desired
* <pre>
* repeat("", 2) = ""
* repeat("cat", 3) = "catcatcat"
* </pre>
*
* @return the new StringColumn
*/
default StringColumn repeat(int times) {
StringColumn newColumn = StringColumn.create(String.format("%s [rep %d]", name(), times));
for (int r = 0; r < size(); r++) {
String value = getString(r);
newColumn.append(StringUtils.repeat(value, times));
}
return newColumn;
}
Aggregations