Package tech.tablesaw.api
Class DateTimeColumn
- All Implemented Interfaces:
Iterable<LocalDateTime>
,Comparator<LocalDateTime>
,CategoricalColumn<LocalDateTime>
,Column<LocalDateTime>
,DateTimeFilters
,DateTimeMapFunctions
,TemporalColumn<LocalDateTime>
,TemporalFillers<LocalDateTime,
,DateTimeColumn> TemporalFilters<LocalDateTime>
,TemporalMapFunctions<DateTimeColumn,
,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
FieldsModifier and TypeFieldDescriptionprotected it.unimi.dsi.fastutil.longs.LongArrayList
The dateTime values held in this column, in theirPackedLocalDateTime
formatFields inherited from class tech.tablesaw.columns.AbstractColumn
DEFAULT_ARRAY_SIZE, DEFAULT_COLUMN_TYPE_MISMATCH_MESSAGE
-
Method Summary
Modifier and TypeMethodDescriptionappend
(LocalDateTime dateTime) Appends value to the bottom of this column and return this columnappend
(Column<LocalDateTime> column) Appends all the values in the argument to the bottom of this column and return this columnappend
(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 columnappendCell
(String stringValue) Add one element to the bottom of this column and set its value to the parsed value of the given String.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 parserappendInternal
(long dateTime) Returns this column with the argument appended at the bottomAppends a missing value appropriate to the columnAppends 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[]
long[]
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[]
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 offsetasInstantColumn
(ZoneId zone) Returns an array of objects as appropriate for my type of columnasSet()
Returns a Set containing all the unique values in this columnbottom
(int n) Returns the smallest ("bottom") n values in the columnint
byteSize()
Returns the width of a cell in this column, in bytes.void
clear()
Removes all elements TODO: Make this return this columnint
compare
(LocalDateTime o1, LocalDateTime o2) boolean
contains
(LocalDateTime dateTime) Returnstrue
if the given object appears in this column, and false otherwisecopy()
Returns a deep copy of the receiverint
Returns the count of missing values in this columnint
Returns the count of unique values in this column.static DateTimeColumn
static DateTimeColumn
static DateTimeColumn
create
(String name, LocalDateTime... data) static DateTimeColumn
create
(String name, Collection<LocalDateTime> data) static DateTimeColumn
create
(String name, Stream<LocalDateTime> stream) static DateTimeColumn
createInternal
(String name, long[] longs) For internal Tablesaw use only Returns a new column with the given name and dataReturns a copy of the receiver with no data.emptyCopy
(int rowSize) Returns an empty copy of the receiver, with its internal storage initialized to the given row size.boolean
equals
(int rowNumber1, int rowNumber2) Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2fillWith
(Iterable<LocalDateTime> iterable) fillWith
(Supplier<LocalDateTime> supplier) fillWith
(Iterator<LocalDateTime> iterator) get
(int index) Returns a value of the Object type stored in the column (e.g. a LocalDateTime) at the given rowdouble
getDouble
(int i) long
getLongInternal
(int index) Returns the internal (long-encoded) value stored in the column at the given rowprotected long
getPackedDateTime
(int index) getString
(int row) Returns a string representation of the value at the given row.getUnformattedString
(int row) Returns a String representation of the value at index r, without any formatting appliedboolean
isEmpty()
Returns true if the column has no databoolean
isMissing
(int rowNumber) Returns true if the value at rowNumber is missingiterator()
Returns an iterator over elements of typeT
.lag
(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.LongIterator
max()
min()
plus
(long amountToAdd, ChronoUnit unit) Returns a copy of this column with the missing values removedit.unimi.dsi.fastutil.ints.IntComparator
Returns an IntComparator for sorting my rowsset
(int index, long value) set
(int index, LocalDateTime value) Sets the value at index row to the given value and return this columnset
(int row, Column<LocalDateTime> column, int sourceRow) Sets the value at row to the value at sourceRow in the given column and return this columnset
(Selection rowSelection, LocalDateTime newValue) Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteriasetMissing
(int i) Sets the value at index i to the missing-value indicator for this column type, and return this columnvoid
setPrintFormatter
(DateTimeFormatter dateTimeFormatter) void
setPrintFormatter
(DateTimeFormatter dateTimeFormatter, String missingValueString) void
setPrintFormatter
(DateTimeColumnFormatter formatter) int
size()
Returns the number of elements in this column, including missing valuesvoid
Sorts my values in ascending ordervoid
Sorts my values in descending ordersubset
(int[] rows) Return a column of the same type containing just those elements whose indexes are included in the given arraysummary()
Returns a table containing a ColumnType specific summary of the data in this columntop
(int n) Returns the largest ("top") n values in the columnunique()
Returns a column of the same type containing only the unique valuesint
valueHash
(int rowNumber) Returns an int suitable as a hash for the value in this column at the given indexstatic boolean
valueIsMissing
(long value) Returns a new column containing the subset referenced by theSelection
Methods inherited from class tech.tablesaw.columns.AbstractColumn
asStringColumn, filter, first, indexOf, inRange, last, 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, 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, minute, minuteOfDay, month, monthValue, plusMonths, 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, lead, missingValues, plusDays, plusHours, plusMicros, plusMillis, plusMinutes, plusSeconds, temporalColumnName
-
Field Details
-
data
protected it.unimi.dsi.fastutil.longs.LongArrayList dataThe dateTime values held in this column, in theirPackedLocalDateTime
format
-
-
Method Details
-
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:
valueHash
in 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:
equals
in interfaceColumn<LocalDateTime>
-
createInternal
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
-
create
-
create
-
create
-
plus
- Specified by:
plus
in interfaceTemporalMapFunctions<DateTimeColumn,
LocalDateTime>
-
create
-
valueIsMissing
public static boolean valueIsMissing(long value) -
isMissing
public boolean isMissing(int rowNumber) Returns true if the value at rowNumber is missing- Specified by:
isMissing
in interfaceColumn<LocalDateTime>
-
subset
Return a column of the same type containing just those elements whose indexes are included in the given array- Specified by:
subset
in interfaceColumn<LocalDateTime>
- Overrides:
subset
in classAbstractColumn<DateTimeColumn,
LocalDateTime>
-
removeMissing
Returns a copy of this column with the missing values removed- Specified by:
removeMissing
in interfaceColumn<LocalDateTime>
-
contains
Returnstrue
if the given object appears in this column, and false otherwiseTODO override in column subtypes for performance
- Specified by:
contains
in interfaceColumn<LocalDateTime>
-
setMissing
Sets the value at index i to the missing-value indicator for this column type, and return this column- Specified by:
setMissing
in interfaceColumn<LocalDateTime>
-
where
Returns a new column containing the subset referenced by theSelection
- Specified by:
where
in interfaceColumn<LocalDateTime>
-
setPrintFormatter
-
setPrintFormatter
-
setPrintFormatter
-
lag
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:
lag
in interfaceColumn<LocalDateTime>
- Specified by:
lag
in interfaceTemporalMapFunctions<DateTimeColumn,
LocalDateTime>
-
appendCell
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:
appendCell
in interfaceColumn<LocalDateTime>
-
appendCell
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:
appendCell
in interfaceColumn<LocalDateTime>
-
append
Appends value to the bottom of this column and return this column- Specified by:
append
in interfaceColumn<LocalDateTime>
-
appendObj
Appends the given value to the bottom of this column and return this column- Specified by:
appendObj
in interfaceColumn<LocalDateTime>
-
size
public int size()Returns the number of elements in this column, including missing values- Specified by:
size
in interfaceColumn<LocalDateTime>
- Specified by:
size
in interfaceTemporalFilters<LocalDateTime>
-
appendInternal
Returns this column with the argument appended at the bottom- Specified by:
appendInternal
in interfaceTemporalColumn<LocalDateTime>
-
getString
Returns a string representation of the value at the given row.- Specified by:
getString
in interfaceColumn<LocalDateTime>
- Parameters:
row
- The index of the row.- Returns:
- value as String
-
getUnformattedString
Returns a String representation of the value at index r, without any formatting applied- Specified by:
getUnformattedString
in interfaceColumn<LocalDateTime>
-
emptyCopy
Returns a copy of the receiver with no data. The column name and type are the same.- Specified by:
emptyCopy
in interfaceColumn<LocalDateTime>
- Specified by:
emptyCopy
in interfaceTemporalMapFunctions<DateTimeColumn,
LocalDateTime> - Returns:
- a empty copy of
Column
-
emptyCopy
Returns an empty copy of the receiver, with its internal storage initialized to the given row size.- Specified by:
emptyCopy
in interfaceColumn<LocalDateTime>
- Parameters:
rowSize
- the initial row size- Returns:
- a
Column
-
copy
Returns a deep copy of the receiver- Specified by:
copy
in interfaceColumn<LocalDateTime>
- Returns:
- a
Column
-
clear
public void clear()Removes all elements TODO: Make this return this column- Specified by:
clear
in interfaceColumn<LocalDateTime>
-
sortAscending
public void sortAscending()Sorts my values in ascending order- Specified by:
sortAscending
in interfaceColumn<LocalDateTime>
-
sortDescending
public void sortDescending()Sorts my values in descending order- Specified by:
sortDescending
in interfaceColumn<LocalDateTime>
-
summary
Returns a table containing a ColumnType specific summary of the data in this column- Specified by:
summary
in interfaceColumn<LocalDateTime>
-
countUnique
public int countUnique()Returns the count of unique values in this column.- Specified by:
countUnique
in interfaceColumn<LocalDateTime>
- Returns:
- unique values as int
-
unique
Returns a column of the same type containing only the unique values- Specified by:
unique
in interfaceColumn<LocalDateTime>
- Returns:
- a
Column
-
isEmpty
public boolean isEmpty()Returns true if the column has no data- Specified by:
isEmpty
in 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:
getLongInternal
in interfaceTemporalColumn<LocalDateTime>
- Specified by:
getLongInternal
in interfaceTemporalFilters<LocalDateTime>
-
getPackedDateTime
protected long getPackedDateTime(int index) -
get
Returns a value of the Object type stored in the column (e.g. a LocalDateTime) at the given row- Specified by:
get
in interfaceColumn<LocalDateTime>
- Specified by:
get
in interfaceTemporalColumn<LocalDateTime>
- Specified by:
get
in interfaceTemporalFilters<LocalDateTime>
-
rowComparator
public it.unimi.dsi.fastutil.ints.IntComparator rowComparator()Returns an IntComparator for sorting my rows- Specified by:
rowComparator
in interfaceColumn<LocalDateTime>
-
set
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:
set
in interfaceColumn<LocalDateTime>
- Overrides:
set
in classAbstractColumn<DateTimeColumn,
LocalDateTime>
-
countMissing
public int countMissing()Returns the count of missing values in this column- Specified by:
countMissing
in 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
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
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
-
asInstantColumn
-
append
Appends all the values in the argument to the bottom of this column and return this column- Specified by:
append
in interfaceColumn<LocalDateTime>
-
append
Appends the value at the given row in the given column to the bottom of this column and return this column- Specified by:
append
in interfaceColumn<LocalDateTime>
-
set
Sets the value at row to the value at sourceRow in the given column and return this column- Specified by:
set
in interfaceColumn<LocalDateTime>
-
max
-
appendMissing
Appends a missing value appropriate to the column- Specified by:
appendMissing
in interfaceColumn<LocalDateTime>
-
min
- Specified by:
min
in interfaceTemporalMapFunctions<DateTimeColumn,
LocalDateTime>
-
set
-
set
Sets the value at index row to the given value and return this column- Specified by:
set
in interfaceColumn<LocalDateTime>
-
top
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
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
Description copied from interface:Column
Returns a Set containing all the unique values in this column- Specified by:
asSet
in interfaceColumn<LocalDateTime>
-
byteSize
public int byteSize()Returns the width of a cell in this column, in bytes.- Specified by:
byteSize
in 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:
asBytes
in interfaceColumn<LocalDateTime>
- Parameters:
rowNumber
- index of the row- Returns:
- content as byte[]
-
getDouble
public double getDouble(int i) -
asDoubleArray
public double[] asDoubleArray() -
asDoubleColumn
-
iterator
Returns an iterator over elements of typeT
.- Specified by:
iterator
in interfaceIterable<LocalDateTime>
- Returns:
- an Iterator.
-
fillWith
- Specified by:
fillWith
in interfaceTemporalFillers<LocalDateTime,
DateTimeColumn>
-
fillWith
- Specified by:
fillWith
in interfaceTemporalFillers<LocalDateTime,
DateTimeColumn>
-
fillWith
- Specified by:
fillWith
in interfaceTemporalFillers<LocalDateTime,
DateTimeColumn>
-
asObjectArray
Returns an array of objects as appropriate for my type of column- Specified by:
asObjectArray
in interfaceColumn<LocalDateTime>
-
compare
- Specified by:
compare
in interfaceComparator<LocalDateTime>
-