Package tech.tablesaw.api
Class TimeColumn
- java.lang.Object
-
- tech.tablesaw.columns.AbstractColumn<TimeColumn,LocalTime>
-
- tech.tablesaw.api.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
Fields Modifier and Type Field Description protected it.unimi.dsi.fastutil.ints.IntArrayList
data
-
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 TimeColumn
append(LocalTime time)
Appends value to the bottom of this column and return this columnTimeColumn
append(Column<LocalTime> column)
Appends all the values in the argument to the bottom of this column and return this columnTimeColumn
append(Column<LocalTime> column, int row)
Appends the value at the given row in the given column to the bottom of this column and return this columnTimeColumn
appendCell(String object)
Add one element to the bottom of this column and set its value to the parsed value of the given String.TimeColumn
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 parserTimeColumn
appendInternal(int f)
TimeColumn
appendMissing()
Appends a missing value appropriate to the columnTimeColumn
appendObj(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()
DoubleColumn
asDoubleColumn()
List<LocalTime>
asList()
Returns the entire contents of this column as a listLocalTime[]
asObjectArray()
Returns an array of objects as appropriate for my type of columnSet<LocalTime>
asSet()
Returns a Set containing all the unique values in this columnList<LocalTime>
bottom(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
compare(LocalTime o1, LocalTime o2)
boolean
contains(LocalTime time)
Returnstrue
if the given object appears in this column, and false otherwiseTimeColumn
copy()
Returns a deep copy of the receiverint
countMissing()
Returns the count of missing values in this columnint
countUnique()
Returns the count of unique values in this column.static TimeColumn
create(String name)
static TimeColumn
create(String name, int initialSize)
static TimeColumn
create(String name, LocalTime... data)
static TimeColumn
create(String name, Collection<LocalTime> data)
static TimeColumn
create(String name, Stream<LocalTime> stream)
static TimeColumn
create(String name, AbstractColumnParser<LocalTime> parser)
static TimeColumn
createInternal(String name, int[] data)
TimeColumn
emptyCopy()
Returns a copy of the receiver with no data.TimeColumn
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 rowNumber2TimeColumn
fillWith(Iterable<LocalTime> iterable)
TimeColumn
fillWith(Supplier<LocalTime> supplier)
TimeColumn
fillWith(Iterator<LocalTime> iterator)
LocalTime
get(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)
String
getString(int row)
Returns a string representation of the value at the given row.String
getUnformattedString(int row)
Returns a String representation of the value at index r, without any formatting appliedit.unimi.dsi.fastutil.ints.IntIterator
intIterator()
boolean
isEmpty()
Returns true if the column has no dataSelection
isMissing()
Returns a selection containing an index for every missing value in this columnboolean
isMissing(int rowNumber)
Returns true if the value at rowNumber is missingSelection
isNotMissing()
Returns a selection containing an index for every non-missing value in this columnIterator<LocalTime>
iterator()
Returns an iterator over elements of typeT
.TimeColumn
lag(int n)
Returns a column of the same type and size as the receiver, containing the receivers values offset by n.LocalTime
max()
LocalTime
min()
TimeColumn
removeMissing()
Returns a copy of this column with the missing values removedit.unimi.dsi.fastutil.ints.IntComparator
rowComparator()
Returns an IntComparator for sorting my rowsTimeColumn
set(int index, int value)
TimeColumn
set(int index, LocalTime value)
Sets the value at index row to the given value and return this columnTimeColumn
set(int row, Column<LocalTime> column, int sourceRow)
Sets the value at row to the value at sourceRow in the given column and return this columnTimeColumn
set(Selection rowSelection, LocalTime newValue)
Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteriaTimeColumn
setMissing(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
sortAscending()
Sorts my values in ascending ordervoid
sortDescending()
Sorts my values in descending orderTimeColumn
subset(int[] rows)
Return a column of the same type containing just those elements whose indexes are included in the given arrayTable
summary()
Returns a table containing a ColumnType specific summary of the data in this columnList<LocalTime>
top(int n)
Returns the largest ("top") n values in the column.String
toString()
TimeColumn
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)
TimeColumn
where(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, 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, 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 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
-
-
-
-
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
-
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
public static TimeColumn createInternal(String name, int[] data)
-
valueIsMissing
public static boolean valueIsMissing(int i)
-
create
public static TimeColumn create(String name)
-
create
public static TimeColumn create(String name, AbstractColumnParser<LocalTime> parser)
-
create
public static TimeColumn create(String name, Collection<LocalTime> data)
-
create
public static TimeColumn create(String name, LocalTime... data)
-
create
public static TimeColumn create(String name, int initialSize)
-
create
public static TimeColumn create(String name, Stream<LocalTime> stream)
-
appendMissing
public TimeColumn appendMissing()
Appends a missing value appropriate to the column- Specified by:
appendMissing
in interfaceColumn<LocalTime>
-
subset
public TimeColumn subset(int[] rows)
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
public TimeColumn 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:
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
public TimeColumn appendInternal(int f)
-
append
public TimeColumn append(LocalTime time)
Appends value to the bottom of this column and return this column
-
appendObj
public TimeColumn appendObj(Object obj)
Appends the given value to the bottom of this column and return this column
-
removeMissing
public TimeColumn removeMissing()
Returns a copy of this column with the missing values removed- Specified by:
removeMissing
in interfaceColumn<LocalTime>
-
getString
public String getString(int row)
Returns a string representation of the value at the given row.
-
getUnformattedString
public String getUnformattedString(int row)
Returns a String representation of the value at index r, without any formatting applied- Specified by:
getUnformattedString
in interfaceColumn<LocalTime>
-
setPrintFormatter
public void setPrintFormatter(DateTimeFormatter dateTimeFormatter, String missingValueString)
-
setPrintFormatter
public void setPrintFormatter(DateTimeFormatter dateTimeFormatter)
-
emptyCopy
public TimeColumn emptyCopy()
Returns a copy of the receiver with no data. The column name and type are the same.- Specified by:
emptyCopy
in interfaceColumn<LocalTime>
- Specified by:
emptyCopy
in classAbstractColumn<TimeColumn,LocalTime>
- Returns:
- a empty copy of
Column
-
emptyCopy
public TimeColumn emptyCopy(int rowSize)
Returns an empty copy of the receiver, with its internal storage initialized to the given row size.
-
copy
public TimeColumn copy()
Returns a deep copy of the receiver
-
clear
public void clear()
Removes all elements TODO: Make this return this column
-
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
public LocalTime max()
-
min
public LocalTime min()
- Specified by:
min
in interfaceTimeMapFunctions
-
summary
public Table 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
public TimeColumn 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
public TimeColumn appendCell(String object)
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
public TimeColumn 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 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
public LocalTime get(int index)
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
public DoubleColumn asDoubleColumn()
-
toString
public String toString()
- Overrides:
toString
in classAbstractColumn<TimeColumn,LocalTime>
-
append
public TimeColumn append(Column<LocalTime> column)
Appends all the values in the argument to the bottom of this column and return this column
-
append
public TimeColumn append(Column<LocalTime> column, int row)
Appends the value at the given row in the given column to the bottom of this column and return this column
-
set
public TimeColumn set(int row, Column<LocalTime> column, int sourceRow)
Sets the value at row to the value at sourceRow in the given column and return this column
-
top
public List<LocalTime> top(int n)
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
public List<LocalTime> bottom(int n)
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
public TimeColumn set(int index, int value)
-
set
public TimeColumn set(int index, LocalTime value)
Sets the value at index row to the given value and return this column
-
set
public TimeColumn set(Selection rowSelection, LocalTime 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(), 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
public boolean contains(LocalTime time)
Returnstrue
if the given object appears in this column, and false otherwiseTODO override in column subtypes for performance
-
asSet
public Set<LocalTime> asSet()
Description copied from interface:Column
Returns a Set containing all the unique values in this column
-
setMissing
public TimeColumn setMissing(int i)
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
public Selection isMissing()
Returns a selection containing an index for every missing value in this column
-
isNotMissing
public Selection 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[]
-
where
public TimeColumn where(Selection selection)
Returns a new column containing the subset referenced by theSelection
- Specified by:
where
in interfaceColumn<LocalTime>
- Specified by:
where
in interfaceTimeFilters
-
asObjectArray
public LocalTime[] 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
public TimeColumn fillWith(Iterator<LocalTime> iterator)
- Specified by:
fillWith
in interfaceTimeFillers<TimeColumn>
-
fillWith
public TimeColumn fillWith(Iterable<LocalTime> iterable)
- Specified by:
fillWith
in interfaceTimeFillers<TimeColumn>
-
fillWith
public TimeColumn fillWith(Supplier<LocalTime> supplier)
- Specified by:
fillWith
in interfaceTimeFillers<TimeColumn>
-
compare
public int compare(LocalTime o1, LocalTime o2)
- Specified by:
compare
in interfaceComparator<LocalTime>
-
-