Package tech.tablesaw.api
Class TimeColumn
- All Implemented Interfaces:
Iterable<LocalTime>
,Comparator<LocalTime>
,CategoricalColumn<LocalTime>
,Column<LocalTime>
,TimeFillers<TimeColumn>
,TimeFilters
,TimeMapFunctions
public class TimeColumn
extends AbstractColumn<TimeColumn,LocalTime>
implements CategoricalColumn<LocalTime>, TimeFilters, TimeFillers<TimeColumn>, TimeMapFunctions
A column that contains int-encoded local time values
-
Field Summary
FieldsFields inherited from class tech.tablesaw.columns.AbstractColumn
DEFAULT_ARRAY_SIZE, DEFAULT_COLUMN_TYPE_MISMATCH_MESSAGE
-
Method Summary
Modifier and TypeMethodDescriptionAppends value to the bottom of this column and return this columnAppends all the values in the argument to the bottom of this column and return this columnAppends the value at the given row in the given column to the bottom of this column and return this columnappendCell
(String object) Add one element to the bottom of this column and set its value to the parsed value of the given String.appendCell
(String object, 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
(int f) Appends 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[]
asList()
Returns the entire contents of this column as a listReturns 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 column, Does not change the order in this columnint
byteSize()
Returns the width of a cell in this column, in bytes.void
clear()
Removes all elements TODO: Make this return this columnint
boolean
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 TimeColumn
static TimeColumn
static TimeColumn
static TimeColumn
create
(String name, Collection<LocalTime> data) static TimeColumn
static TimeColumn
create
(String name, AbstractColumnParser<LocalTime> parser) static TimeColumn
createInternal
(String name, int[] data) Returns 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 rowNumber2get
(int index) Returns the value at the given zero-based indexdouble
getDouble
(int i) int
getIntInternal
(int index) Returns the packed time representation of the value at indexprotected int
getPackedTime
(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 appliedit.unimi.dsi.fastutil.ints.IntIterator
boolean
isEmpty()
Returns true if the column has no dataReturns a selection containing an index for every missing value in this columnboolean
isMissing
(int rowNumber) Returns true if the value at rowNumber is missingReturns a selection containing an index for every non-missing value in this columniterator()
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.max()
min()
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, int value) Sets the value at index row to the given value and return this columnSets the value at row to the value at sourceRow in the given column and return this columnConditionally 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) 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 column.toString()
unique()
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
(int i) 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, 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, 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 java.lang.Iterable
forEach, spliterator
Methods inherited from interface tech.tablesaw.columns.times.TimeFilters
eval, eval, eval, eval, eval, isAfter, isAfter, isAfter, isAfterNoon, isBefore, isBefore, isBefore, isBeforeNoon, isEqualTo, isEqualTo, isMidnight, isNoon, isNotEqualTo, isNotEqualTo, isOnOrAfter, isOnOrAfter, isOnOrBefore, isOnOrBefore
Methods inherited from interface tech.tablesaw.columns.times.TimeMapFunctions
difference, differenceInHours, differenceInMilliseconds, differenceInMinutes, differenceInSeconds, hour, hourMinute, lead, milliseconds, minus, minusHours, minusMilliseconds, minusMinutes, minusSeconds, minute, minuteOfDay, plus, plusHours, plusMilliseconds, plusMinutes, plusSeconds, second, secondOfDay, timeWindow, timeWindow, truncatedTo, with, withHour, withMillisecond, withMinute, withSecond
-
Field Details
-
data
protected it.unimi.dsi.fastutil.ints.IntArrayList data
-
-
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 -
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 -
createInternal
-
valueIsMissing
public static boolean valueIsMissing(int i) -
create
-
create
-
create
-
create
-
create
-
create
-
appendMissing
Appends a missing value appropriate to the column- Specified by:
appendMissing
in interfaceColumn<LocalTime>
-
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<LocalTime>
- Overrides:
subset
in classAbstractColumn<TimeColumn,
LocalTime>
-
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<LocalTime>
- Specified by:
lag
in interfaceTimeMapFunctions
-
isMissing
public boolean isMissing(int rowNumber) Returns true if the value at rowNumber is missing -
size
public int size()Returns the number of elements in this column, including missing values -
appendInternal
-
append
Appends value to the bottom of this column and return this column -
appendObj
Appends the given value to the bottom of this column and return this column -
removeMissing
Returns a copy of this column with the missing values removed- Specified by:
removeMissing
in interfaceColumn<LocalTime>
-
getString
Returns a string representation of the value at the given row. -
getUnformattedString
Returns a String representation of the value at index r, without any formatting applied- Specified by:
getUnformattedString
in interfaceColumn<LocalTime>
-
setPrintFormatter
-
setPrintFormatter
-
emptyCopy
Returns a copy of the receiver with no data. The column name and type are the same. -
emptyCopy
Returns an empty copy of the receiver, with its internal storage initialized to the given row size. -
copy
Returns a deep copy of the receiver -
clear
public void clear()Removes all elements TODO: Make this return this column -
asList
Returns the entire contents of this column as a list -
sortAscending
public void sortAscending()Sorts my values in ascending order- Specified by:
sortAscending
in interfaceColumn<LocalTime>
-
sortDescending
public void sortDescending()Sorts my values in descending order- Specified by:
sortDescending
in interfaceColumn<LocalTime>
-
max
-
min
- Specified by:
min
in interfaceTimeMapFunctions
-
summary
Returns a table containing a ColumnType specific summary of the data in this column -
countMissing
public int countMissing()Returns the count of missing values in this column- Specified by:
countMissing
in interfaceColumn<LocalTime>
- Returns:
- missing values as int
-
countUnique
public int countUnique()Returns the count of unique values in this column.- Specified by:
countUnique
in interfaceColumn<LocalTime>
- Returns:
- unique values as int
-
unique
Returns a column of the same type containing only the unique values -
isEmpty
public boolean isEmpty()Returns true if the column has no data -
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<LocalTime>
-
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<LocalTime>
-
getIntInternal
public int getIntInternal(int index) Returns the packed time representation of the value at index- Specified by:
getIntInternal
in interfaceTimeFilters
- Specified by:
getIntInternal
in interfaceTimeMapFunctions
-
getPackedTime
protected int getPackedTime(int index) -
get
Returns the value at the given zero-based index- Specified by:
get
in interfaceColumn<LocalTime>
- Specified by:
get
in interfaceTimeFilters
- Specified by:
get
in interfaceTimeMapFunctions
-
rowComparator
public it.unimi.dsi.fastutil.ints.IntComparator rowComparator()Returns an IntComparator for sorting my rows- Specified by:
rowComparator
in interfaceColumn<LocalTime>
-
getDouble
public double getDouble(int i) -
asDoubleArray
public double[] asDoubleArray() -
asDoubleColumn
-
toString
- Overrides:
toString
in classAbstractColumn<TimeColumn,
LocalTime>
-
append
Appends all the values in the argument to the bottom of this column and return this column -
append
Appends the value at the given row in the given column to the bottom of this column and return this column -
set
Sets the value at row to the value at sourceRow in the given column and return this column -
top
Returns the largest ("top") n values in the column. Does not change the order in this 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, Does not change the order in this 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
-
set
-
set
Sets the value at index row to the given value and return this column -
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(), LocalTime.now()); // no more missing values
- Specified by:
set
in interfaceColumn<LocalTime>
- Overrides:
set
in classAbstractColumn<TimeColumn,
LocalTime>
-
intIterator
public it.unimi.dsi.fastutil.ints.IntIterator intIterator() -
contains
Returnstrue
if the given object appears in this column, and false otherwiseTODO override in column subtypes for performance
-
asSet
Description copied from interface:Column
Returns a Set containing all the unique values in this column -
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<LocalTime>
-
isMissing
Returns a selection containing an index for every missing value in this column -
isNotMissing
Returns a selection containing an index for every non-missing value in this column- Specified by:
isNotMissing
in interfaceColumn<LocalTime>
-
byteSize
public int byteSize()Returns the width of a cell in this column, in bytes. -
asBytes
public byte[] asBytes(int rowNumber) Returns the contents of the cell at rowNumber as a byte[] -
iterator
Returns an iterator over elements of typeT
. -
where
Returns a new column containing the subset referenced by theSelection
- Specified by:
where
in interfaceColumn<LocalTime>
- Specified by:
where
in interfaceTimeFilters
-
asObjectArray
Description copied from interface:Column
Returns an array of objects as appropriate for my type of column- Specified by:
asObjectArray
in interfaceColumn<LocalTime>
-
fillWith
- Specified by:
fillWith
in interfaceTimeFillers<TimeColumn>
-
fillWith
- Specified by:
fillWith
in interfaceTimeFillers<TimeColumn>
-
fillWith
- Specified by:
fillWith
in interfaceTimeFillers<TimeColumn>
-
compare
- Specified by:
compare
in interfaceComparator<LocalTime>
-