use of tech.tablesaw.api.IntColumn in project symja_android_library by axkr.
the class DateTimeMapFunctions method dayOfYear.
default IntColumn dayOfYear() {
IntColumn newColumn = IntColumn.create(this.name() + " day of year", this.size());
for (int r = 0; r < this.size(); r++) {
if (!isMissing(r)) {
long c1 = this.getLongInternal(r);
newColumn.set(r, (short) getDayOfYear(c1));
}
}
return newColumn;
}
use of tech.tablesaw.api.IntColumn in project symja_android_library by axkr.
the class DateTimeMapFunctions method year.
default IntColumn year() {
IntColumn newColumn = IntColumn.create(this.name() + " year");
for (int r = 0; r < this.size(); r++) {
if (isMissing(r)) {
newColumn.appendMissing();
} else {
long c1 = getLongInternal(r);
newColumn.append(PackedLocalDate.getYear(PackedLocalDateTime.date(c1)));
}
}
return newColumn;
}
use of tech.tablesaw.api.IntColumn in project symja_android_library by axkr.
the class DateTimeMapFunctions method dayOfWeekValue.
default IntColumn dayOfWeekValue() {
IntColumn newColumn = IntColumn.create(this.name() + " day of week value", this.size());
for (int r = 0; r < this.size(); r++) {
if (!isMissing(r)) {
long c1 = this.getLongInternal(r);
newColumn.set(r, (short) getDayOfWeek(c1).getValue());
}
}
return newColumn;
}
use of tech.tablesaw.api.IntColumn in project symja_android_library by axkr.
the class DateTimeMapFunctions method monthValue.
default IntColumn monthValue() {
IntColumn newColumn = IntColumn.create(this.name() + " month");
for (int r = 0; r < this.size(); r++) {
if (isMissing(r)) {
newColumn.appendMissing();
} else {
long c1 = getLongInternal(r);
newColumn.append((short) getMonthValue(c1));
}
}
return newColumn;
}
use of tech.tablesaw.api.IntColumn in project symja_android_library by axkr.
the class DateMapFunctions method timeUntil.
/**
* Calculates the temporal difference between each element of the receiver and the respective
* element of the argument
*
* <p>Missing values in either result in a Missing Value for the new column
*/
default IntColumn timeUntil(DateColumn end, ChronoUnit unit) {
IntColumn newColumn = IntColumn.create(name() + " - " + end.name() + "[" + unit.name() + "]");
for (int r = 0; r < size(); r++) {
int c1 = getIntInternal(r);
int c2 = end.getIntInternal(r);
if (valueIsMissing(c1) || valueIsMissing(c2)) {
newColumn.appendMissing();
} else {
switch(unit) {
case DAYS:
newColumn.append(PackedLocalDate.daysUntil(c2, c1));
break;
case WEEKS:
newColumn.append(PackedLocalDate.weeksUntil(c2, c1));
break;
case MONTHS:
newColumn.append(PackedLocalDate.monthsUntil(c2, c1));
break;
case YEARS:
newColumn.append(PackedLocalDate.yearsUntil(c2, c1));
break;
default:
// handle decades, etc.
LocalDate value1 = PackedLocalDate.asLocalDate(c1);
LocalDate value2 = PackedLocalDate.asLocalDate(c2);
if (value1 == null || value2 == null) {
newColumn.appendMissing();
} else {
newColumn.append((int) unit.between(value1, value2));
}
break;
}
}
}
return newColumn;
}
Aggregations