Package tech.tablesaw.api
Class DateTimeColumn
- java.lang.Object
-
- tech.tablesaw.columns.AbstractColumn<DateTimeColumn,LocalDateTime>
-
- tech.tablesaw.api.DateTimeColumn
-
- All Implemented Interfaces:
Iterable<LocalDateTime>,Comparator<LocalDateTime>,CategoricalColumn<LocalDateTime>,Column<LocalDateTime>,DateTimeFilters,DateTimeMapFunctions,TemporalColumn<LocalDateTime>,TemporalFillers<LocalDateTime,DateTimeColumn>,TemporalFilters<LocalDateTime>,TemporalMapFunctions<LocalDateTime>,DateAndDateTimeFilterSpec<Selection>,DateTimeFilterSpec<Selection>,FilterSpec<Selection>,InstantFilterSpec<Selection>,TimeAndDateTimeFilterSpec<Selection>
public class DateTimeColumn extends AbstractColumn<DateTimeColumn,LocalDateTime> implements DateTimeMapFunctions, DateTimeFilters, TemporalFillers<LocalDateTime,DateTimeColumn>, CategoricalColumn<LocalDateTime>
A column that contains long-integer encoded (packed) local date-time values
-
-
Field Summary
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.longs.LongArrayListdataThe dateTime values held in this column, in theirPackedLocalDateTimeformat-
Fields inherited from class tech.tablesaw.columns.AbstractColumn
DEFAULT_ARRAY_SIZE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DateTimeColumnappend(LocalDateTime dateTime)Appends value to the bottom of this column and return this columnDateTimeColumnappend(Column<LocalDateTime> column)Appends all the values in the argument to the bottom of this column and return this columnDateTimeColumnappend(Column<LocalDateTime> column, int row)Appends the value at the given row in the given column to the bottom of this column and return this columnDateTimeColumnappendCell(String stringValue)Add one element to the bottom of this column and set its value to the parsed value of the given String.DateTimeColumnappendCell(String stringValue, AbstractColumnParser<?> parser)Add one element to the bottom of this column and set its value to the parsed value of the given String, as performed by the given parserDateTimeColumnappendInternal(long dateTime)Returns this column with the argument appended at the bottomDateTimeColumnappendMissing()Appends a missing value appropriate to the columnDateTimeColumnappendObj(Object obj)Appends the given value to the bottom of this column and return this columnbyte[]asBytes(int rowNumber)Returns the contents of the cell at rowNumber as a byte[]double[]asDoubleArray()DoubleColumnasDoubleColumn()long[]asEpochMillisArray()Returns an array where each entry is the difference, measured in milliseconds, between the LocalDateTime and midnight, January 1, 1970 UTC.long[]asEpochMillisArray(ZoneOffset offset)Returns an array where each entry is the difference, measured in milliseconds, between the LocalDateTime and midnight, January 1, 1970 UTC.long[]asEpochSecondArray()Returns an array where each entry is the difference, measured in seconds, between the LocalDateTime and midnight, January 1, 1970 UTC.long[]asEpochSecondArray(ZoneOffset offset)Returns the seconds from epoch for each value as an array based on the given offsetInstantColumnasInstantColumn()InstantColumnasInstantColumn(ZoneId zone)LocalDateTime[]asObjectArray()Returns an array of objects as appropriate for my type of columnSet<LocalDateTime>asSet()Returns a Set containing all the unique values in this columnList<LocalDateTime>bottom(int n)Returns the smallest ("bottom") n values in the columnintbyteSize()Returns the width of a cell in this column, in bytes.voidclear()Removes all elements TODO: Make this return this columnintcompare(LocalDateTime o1, LocalDateTime o2)booleancontains(LocalDateTime dateTime)Returnstrueif the given object appears in this column, and false otherwiseDateTimeColumncopy()Returns a deep copy of the receiverintcountMissing()Returns the count of missing values in this columnintcountUnique()Returns the count of unique values in this column.static DateTimeColumncreate(String name)static DateTimeColumncreate(String name, int initialSize)static DateTimeColumncreate(String name, LocalDateTime... data)static DateTimeColumncreate(String name, Collection<LocalDateTime> data)static DateTimeColumncreate(String name, Stream<LocalDateTime> stream)static DateTimeColumncreateInternal(String name, long[] longs)For internal Tablesaw use only Returns a new column with the given name and dataDateTimeColumnemptyCopy()Returns a copy of the receiver with no data.DateTimeColumnemptyCopy(int rowSize)Returns an empty copy of the receiver, with its internal storage initialized to the given row size.booleanequals(int rowNumber1, int rowNumber2)Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2DateTimeColumnfillWith(Iterable<LocalDateTime> iterable)DateTimeColumnfillWith(Supplier<LocalDateTime> supplier)DateTimeColumnfillWith(Iterator<LocalDateTime> iterator)LocalDateTimeget(int index)Returns a value of the Object type stored in the column (e.g.doublegetDouble(int i)longgetLongInternal(int index)Returns the internal (long-encoded) value stored in the column at the given rowprotected longgetPackedDateTime(int index)StringgetString(int row)Returns a string representation of the value at the given row.StringgetUnformattedString(int row)Returns a String representation of the value at index r, without any formatting appliedbooleanisEmpty()Returns true if the column has no databooleanisMissing(int rowNumber)Returns true if the value at rowNumber is missingIterator<LocalDateTime>iterator()Returns an iterator over elements of typeT.DateTimeColumnlag(int n)Returns a column of the same type and size as the receiver, containing the receivers values offset by n.it.unimi.dsi.fastutil.longs.LongIteratorlongIterator()LocalDateTimemax()LocalDateTimemin()DateTimeColumnplus(long amountToAdd, ChronoUnit unit)DateTimeColumnremoveMissing()Returns a copy of this column with the missing values removedit.unimi.dsi.fastutil.ints.IntComparatorrowComparator()Returns an IntComparator for sorting my rowsDateTimeColumnset(int index, long value)DateTimeColumnset(int index, LocalDateTime value)Sets the value at index row to the given value and return this columnDateTimeColumnset(int row, Column<LocalDateTime> column, int sourceRow)Sets the value at row to the value at sourceRow in the given column and return this columnDateTimeColumnset(Selection rowSelection, LocalDateTime newValue)Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteriaDateTimeColumnsetMissing(int i)Sets the value at index i to the missing-value indicator for this column type, and return this columnvoidsetPrintFormatter(DateTimeFormatter dateTimeFormatter)voidsetPrintFormatter(DateTimeFormatter dateTimeFormatter, String missingValueString)voidsetPrintFormatter(DateTimeColumnFormatter formatter)intsize()Returns the number of elements in this column, including missing valuesvoidsortAscending()Sorts my values in ascending ordervoidsortDescending()Sorts my values in descending orderDateTimeColumnsubset(int[] rows)Return a column of the same type containing just those elements whose indexes are included in the given arrayTablesummary()Returns a table containing a ColumnType specific summary of the data in this columnList<LocalDateTime>top(int n)Returns the largest ("top") n values in the columnDateTimeColumnunique()Returns a column of the same type containing only the unique valuesintvalueHash(int rowNumber)Returns an int suitable as a hash for the value in this column at the given indexstatic booleanvalueIsMissing(long value)DateTimeColumnwhere(Selection selection)Returns a new column containing the subset referenced by theSelection-
Methods inherited from class tech.tablesaw.columns.AbstractColumn
asStringColumn, filter, first, indexOf, inRange, last, lastIndexOf, map, max, min, name, parser, sampleN, sampleX, set, setName, setParser, sorted, toString, type
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface tech.tablesaw.api.CategoricalColumn
countByCategory
-
Methods inherited from interface tech.tablesaw.columns.Column
allMatch, anyMatch, asList, asStringColumn, columnWidth, count, count, filter, first, indexOf, inRange, interpolate, last, lastIndexOf, map, map, mapInto, max, max, min, min, name, noneMatch, parser, print, reduce, reduce, rolling, sampleN, sampleX, set, set, set, setMissingTo, setName, setParser, sorted, title, type
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface tech.tablesaw.columns.datetimes.DateTimeFilters
isAfter, isAfter, isAfter, isAfterNoon, isBefore, isBefore, isBefore, isBeforeNoon, isBetweenExcluding, isBetweenIncluding, isEqualTo, isEqualTo, isFirstDayOfMonth, isFriday, isInApril, isInAugust, isInDecember, isInFebruary, isInJanuary, isInJuly, isInJune, isInMarch, isInMay, isInNovember, isInOctober, isInQ1, isInQ2, isInQ3, isInQ4, isInSeptember, isInYear, isLastDayOfMonth, isMidnight, isMissing, isMonday, isNoon, isNotEqualTo, isNotEqualTo, isNotMissing, isOnOrAfter, isOnOrAfter, isOnOrAfter, isOnOrBefore, isOnOrBefore, isOnOrBefore, isSaturday, isSunday, isThursday, isTuesday, isWednesday
-
Methods inherited from interface tech.tablesaw.columns.datetimes.DateTimeMapFunctions
date, dayOfMonth, dayOfWeek, dayOfWeekValue, dayOfYear, hour, hourMinute, lead, minute, minuteOfDay, month, monthValue, plusDays, plusHours, plusMicros, plusMillis, plusMinutes, plusMonths, plusSeconds, plusWeeks, plusYears, secondOfDay, time, timeWindow, timeWindow, year, yearDay, yearMonth, yearQuarter, yearWeek
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface tech.tablesaw.columns.temporal.TemporalFilters
eval, eval, eval, eval, eval, isAfter, isBefore, isBetweenExcluding, isBetweenIncluding, isEqualTo
-
Methods inherited from interface tech.tablesaw.columns.temporal.TemporalMapFunctions
difference, differenceInDays, differenceInHours, differenceInMilliseconds, differenceInMinutes, differenceInSeconds, differenceInYears, missingValues, temporalColumnName
-
-
-
-
Field Detail
-
data
protected it.unimi.dsi.fastutil.longs.LongArrayList data
The dateTime values held in this column, in theirPackedLocalDateTimeformat
-
-
Method Detail
-
valueHash
public int valueHash(int rowNumber)
Returns an int suitable as a hash for the value in this column at the given index- Specified by:
valueHashin interfaceColumn<LocalDateTime>
-
equals
public boolean equals(int rowNumber1, int rowNumber2)Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2- Specified by:
equalsin interfaceColumn<LocalDateTime>
-
createInternal
public static DateTimeColumn createInternal(String name, long[] longs)
For internal Tablesaw use only Returns a new column with the given name and data- Parameters:
name- The column namelongs- An array of longs representing datetime values in Tablesaw internal format
-
create
public static DateTimeColumn create(String name)
-
create
public static DateTimeColumn create(String name, int initialSize)
-
create
public static DateTimeColumn create(String name, Collection<LocalDateTime> data)
-
create
public static DateTimeColumn create(String name, Stream<LocalDateTime> stream)
-
plus
public DateTimeColumn plus(long amountToAdd, ChronoUnit unit)
- Specified by:
plusin interfaceDateTimeMapFunctions- Specified by:
plusin interfaceTemporalMapFunctions<LocalDateTime>
-
create
public static DateTimeColumn create(String name, LocalDateTime... data)
-
valueIsMissing
public static boolean valueIsMissing(long value)
-
isMissing
public boolean isMissing(int rowNumber)
Returns true if the value at rowNumber is missing- Specified by:
isMissingin interfaceColumn<LocalDateTime>
-
subset
public DateTimeColumn subset(int[] rows)
Return a column of the same type containing just those elements whose indexes are included in the given array- Specified by:
subsetin interfaceColumn<LocalDateTime>- Overrides:
subsetin classAbstractColumn<DateTimeColumn,LocalDateTime>
-
removeMissing
public DateTimeColumn removeMissing()
Returns a copy of this column with the missing values removed- Specified by:
removeMissingin interfaceColumn<LocalDateTime>
-
contains
public boolean contains(LocalDateTime dateTime)
Returnstrueif the given object appears in this column, and false otherwiseTODO override in column subtypes for performance
- Specified by:
containsin interfaceColumn<LocalDateTime>
-
setMissing
public DateTimeColumn setMissing(int i)
Sets the value at index i to the missing-value indicator for this column type, and return this column- Specified by:
setMissingin interfaceColumn<LocalDateTime>
-
where
public DateTimeColumn where(Selection selection)
Returns a new column containing the subset referenced by theSelection- Specified by:
wherein interfaceColumn<LocalDateTime>
-
setPrintFormatter
public void setPrintFormatter(DateTimeFormatter dateTimeFormatter, String missingValueString)
-
setPrintFormatter
public void setPrintFormatter(DateTimeFormatter dateTimeFormatter)
-
setPrintFormatter
public void setPrintFormatter(DateTimeColumnFormatter formatter)
-
lag
public DateTimeColumn lag(int n)
Returns a column of the same type and size as the receiver, containing the receivers values offset by n.For example if you lag a column containing 2, 3, 4 by 1, you get a column containing NA, 2, 3
- Specified by:
lagin interfaceColumn<LocalDateTime>- Specified by:
lagin interfaceDateTimeMapFunctions
-
appendCell
public DateTimeColumn appendCell(String stringValue)
Add one element to the bottom of this column and set its value to the parsed value of the given String. Parsing is type-specific- Specified by:
appendCellin interfaceColumn<LocalDateTime>
-
appendCell
public DateTimeColumn appendCell(String stringValue, AbstractColumnParser<?> parser)
Add one element to the bottom of this column and set its value to the parsed value of the given String, as performed by the given parser- Specified by:
appendCellin interfaceColumn<LocalDateTime>
-
append
public DateTimeColumn append(LocalDateTime dateTime)
Appends value to the bottom of this column and return this column- Specified by:
appendin interfaceColumn<LocalDateTime>
-
appendObj
public DateTimeColumn appendObj(Object obj)
Appends the given value to the bottom of this column and return this column- Specified by:
appendObjin interfaceColumn<LocalDateTime>
-
size
public int size()
Returns the number of elements in this column, including missing values- Specified by:
sizein interfaceColumn<LocalDateTime>- Specified by:
sizein interfaceTemporalFilters<LocalDateTime>
-
appendInternal
public DateTimeColumn appendInternal(long dateTime)
Returns this column with the argument appended at the bottom- Specified by:
appendInternalin interfaceTemporalColumn<LocalDateTime>
-
getString
public String getString(int row)
Returns a string representation of the value at the given row.- Specified by:
getStringin interfaceColumn<LocalDateTime>- Parameters:
row- The index of the row.- Returns:
- value as String
-
getUnformattedString
public String getUnformattedString(int row)
Returns a String representation of the value at index r, without any formatting applied- Specified by:
getUnformattedStringin interfaceColumn<LocalDateTime>
-
emptyCopy
public DateTimeColumn emptyCopy()
Returns a copy of the receiver with no data. The column name and type are the same.- Specified by:
emptyCopyin interfaceColumn<LocalDateTime>- Specified by:
emptyCopyin interfaceTemporalMapFunctions<LocalDateTime>- Specified by:
emptyCopyin classAbstractColumn<DateTimeColumn,LocalDateTime>- Returns:
- a empty copy of
Column
-
emptyCopy
public DateTimeColumn emptyCopy(int rowSize)
Returns an empty copy of the receiver, with its internal storage initialized to the given row size.- Specified by:
emptyCopyin interfaceColumn<LocalDateTime>- Parameters:
rowSize- the initial row size- Returns:
- a
Column
-
copy
public DateTimeColumn copy()
Returns a deep copy of the receiver- Specified by:
copyin interfaceColumn<LocalDateTime>- Returns:
- a
Column
-
clear
public void clear()
Removes all elements TODO: Make this return this column- Specified by:
clearin interfaceColumn<LocalDateTime>
-
sortAscending
public void sortAscending()
Sorts my values in ascending order- Specified by:
sortAscendingin interfaceColumn<LocalDateTime>
-
sortDescending
public void sortDescending()
Sorts my values in descending order- Specified by:
sortDescendingin interfaceColumn<LocalDateTime>
-
summary
public Table summary()
Returns a table containing a ColumnType specific summary of the data in this column- Specified by:
summaryin interfaceColumn<LocalDateTime>
-
countUnique
public int countUnique()
Returns the count of unique values in this column.- Specified by:
countUniquein interfaceColumn<LocalDateTime>- Returns:
- unique values as int
-
unique
public DateTimeColumn unique()
Returns a column of the same type containing only the unique values- Specified by:
uniquein interfaceColumn<LocalDateTime>- Returns:
- a
Column
-
isEmpty
public boolean isEmpty()
Returns true if the column has no data- Specified by:
isEmptyin interfaceColumn<LocalDateTime>- Returns:
- true if empty, false if not
-
getLongInternal
public long getLongInternal(int index)
Returns the internal (long-encoded) value stored in the column at the given row- Specified by:
getLongInternalin interfaceTemporalColumn<LocalDateTime>- Specified by:
getLongInternalin interfaceTemporalFilters<LocalDateTime>
-
getPackedDateTime
protected long getPackedDateTime(int index)
-
get
public LocalDateTime get(int index)
Returns a value of the Object type stored in the column (e.g. a LocalDateTime) at the given row- Specified by:
getin interfaceColumn<LocalDateTime>- Specified by:
getin interfaceTemporalColumn<LocalDateTime>- Specified by:
getin interfaceTemporalFilters<LocalDateTime>
-
rowComparator
public it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
Returns an IntComparator for sorting my rows- Specified by:
rowComparatorin interfaceColumn<LocalDateTime>
-
set
public DateTimeColumn set(Selection rowSelection, LocalDateTime newValue)
Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteriaExample: myColumn.set(myColumn.valueIsMissing(), LocalDateTime.now()); // no more missing values
- Specified by:
setin interfaceColumn<LocalDateTime>- Overrides:
setin classAbstractColumn<DateTimeColumn,LocalDateTime>
-
countMissing
public int countMissing()
Returns the count of missing values in this column- Specified by:
countMissingin interfaceColumn<LocalDateTime>- Returns:
- missing values as int
-
asEpochSecondArray
public long[] asEpochSecondArray()
Returns an array where each entry is the difference, measured in seconds, between the LocalDateTime and midnight, January 1, 1970 UTC.If a value is missing, DateTimeColumnType.missingValueIndicator() is used
-
asEpochSecondArray
public long[] asEpochSecondArray(ZoneOffset offset)
Returns the seconds from epoch for each value as an array based on the given offsetIf a value is missing, DateTimeColumnType.missingValueIndicator() is used
-
asEpochMillisArray
public long[] asEpochMillisArray()
Returns an array where each entry is the difference, measured in milliseconds, between the LocalDateTime and midnight, January 1, 1970 UTC.If a missing value is encountered, DateTimeColumnType.missingValueIndicator() is inserted in the array
-
asEpochMillisArray
public long[] asEpochMillisArray(ZoneOffset offset)
Returns an array where each entry is the difference, measured in milliseconds, between the LocalDateTime and midnight, January 1, 1970 UTC.If a missing value is encountered, DateTimeColumnType.missingValueIndicator() is inserted in the array
-
asInstantColumn
public InstantColumn asInstantColumn()
-
asInstantColumn
public InstantColumn asInstantColumn(ZoneId zone)
-
append
public DateTimeColumn append(Column<LocalDateTime> column)
Appends all the values in the argument to the bottom of this column and return this column- Specified by:
appendin interfaceColumn<LocalDateTime>
-
append
public DateTimeColumn append(Column<LocalDateTime> column, int row)
Appends the value at the given row in the given column to the bottom of this column and return this column- Specified by:
appendin interfaceColumn<LocalDateTime>
-
set
public DateTimeColumn set(int row, Column<LocalDateTime> column, int sourceRow)
Sets the value at row to the value at sourceRow in the given column and return this column- Specified by:
setin interfaceColumn<LocalDateTime>
-
max
public LocalDateTime max()
-
appendMissing
public DateTimeColumn appendMissing()
Appends a missing value appropriate to the column- Specified by:
appendMissingin interfaceColumn<LocalDateTime>
-
min
public LocalDateTime min()
- Specified by:
minin interfaceTemporalMapFunctions<LocalDateTime>
-
set
public DateTimeColumn set(int index, long value)
-
set
public DateTimeColumn set(int index, LocalDateTime value)
Sets the value at index row to the given value and return this column- Specified by:
setin interfaceColumn<LocalDateTime>
-
top
public List<LocalDateTime> top(int n)
Returns the largest ("top") n values in the column- Parameters:
n- The maximum number of records to return. The actual number will be smaller if n is greater than the number of observations in the column- Returns:
- A list, possibly empty, of the largest observations
-
bottom
public List<LocalDateTime> bottom(int n)
Returns the smallest ("bottom") n values in the column- Parameters:
n- The maximum number of records to return. The actual number will be smaller if n is greater than the number of observations in the column- Returns:
- A list, possibly empty, of the smallest n observations
-
longIterator
public it.unimi.dsi.fastutil.longs.LongIterator longIterator()
-
asSet
public Set<LocalDateTime> asSet()
Description copied from interface:ColumnReturns a Set containing all the unique values in this column- Specified by:
asSetin interfaceColumn<LocalDateTime>
-
byteSize
public int byteSize()
Returns the width of a cell in this column, in bytes.- Specified by:
byteSizein interfaceColumn<LocalDateTime>- Returns:
- width in bytes
-
asBytes
public byte[] asBytes(int rowNumber)
Returns the contents of the cell at rowNumber as a byte[]- Specified by:
asBytesin interfaceColumn<LocalDateTime>- Parameters:
rowNumber- index of the row- Returns:
- content as byte[]
-
getDouble
public double getDouble(int i)
-
asDoubleArray
public double[] asDoubleArray()
-
asDoubleColumn
public DoubleColumn asDoubleColumn()
-
iterator
public Iterator<LocalDateTime> iterator()
Returns an iterator over elements of typeT.- Specified by:
iteratorin interfaceIterable<LocalDateTime>- Returns:
- an Iterator.
-
fillWith
public DateTimeColumn fillWith(Iterator<LocalDateTime> iterator)
- Specified by:
fillWithin interfaceTemporalFillers<LocalDateTime,DateTimeColumn>
-
fillWith
public DateTimeColumn fillWith(Iterable<LocalDateTime> iterable)
- Specified by:
fillWithin interfaceTemporalFillers<LocalDateTime,DateTimeColumn>
-
fillWith
public DateTimeColumn fillWith(Supplier<LocalDateTime> supplier)
- Specified by:
fillWithin interfaceTemporalFillers<LocalDateTime,DateTimeColumn>
-
asObjectArray
public LocalDateTime[] asObjectArray()
Returns an array of objects as appropriate for my type of column- Specified by:
asObjectArrayin interfaceColumn<LocalDateTime>
-
compare
public int compare(LocalDateTime o1, LocalDateTime o2)
- Specified by:
comparein interfaceComparator<LocalDateTime>
-
-