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.IntArrayListdata-
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 TimeColumnappend(LocalTime time)Appends value to the bottom of this column and return this columnTimeColumnappend(Column<LocalTime> column)Appends all the values in the argument to the bottom of this column and return this columnTimeColumnappend(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 columnTimeColumnappendCell(String object)Add one element to the bottom of this column and set its value to the parsed value of the given String.TimeColumnappendCell(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 parserTimeColumnappendInternal(int f)TimeColumnappendMissing()Appends a missing value appropriate to the columnTimeColumnappendObj(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()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 columnintbyteSize()Returns the width of a cell in this column, in bytes.voidclear()Removes all elements TODO: Make this return this columnintcompare(LocalTime o1, LocalTime o2)booleancontains(LocalTime time)Returnstrueif the given object appears in this column, and false otherwiseTimeColumncopy()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 TimeColumncreate(String name)static TimeColumncreate(String name, int initialSize)static TimeColumncreate(String name, LocalTime... data)static TimeColumncreate(String name, Collection<LocalTime> data)static TimeColumncreate(String name, Stream<LocalTime> stream)static TimeColumncreate(String name, AbstractColumnParser<LocalTime> parser)static TimeColumncreateInternal(String name, int[] data)TimeColumnemptyCopy()Returns a copy of the receiver with no data.TimeColumnemptyCopy(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 rowNumber2TimeColumnfillWith(Iterable<LocalTime> iterable)TimeColumnfillWith(Supplier<LocalTime> supplier)TimeColumnfillWith(Iterator<LocalTime> iterator)LocalTimeget(int index)Returns the value at the given zero-based indexdoublegetDouble(int i)intgetIntInternal(int index)Returns the packed time representation of the value at indexprotected intgetPackedTime(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 appliedit.unimi.dsi.fastutil.ints.IntIteratorintIterator()booleanisEmpty()Returns true if the column has no dataSelectionisMissing()Returns a selection containing an index for every missing value in this columnbooleanisMissing(int rowNumber)Returns true if the value at rowNumber is missingSelectionisNotMissing()Returns a selection containing an index for every non-missing value in this columnIterator<LocalTime>iterator()Returns an iterator over elements of typeT.TimeColumnlag(int n)Returns a column of the same type and size as the receiver, containing the receivers values offset by n.LocalTimemax()LocalTimemin()TimeColumnremoveMissing()Returns a copy of this column with the missing values removedit.unimi.dsi.fastutil.ints.IntComparatorrowComparator()Returns an IntComparator for sorting my rowsTimeColumnset(int index, int value)TimeColumnset(int index, LocalTime value)Sets the value at index row to the given value and return this columnTimeColumnset(int row, Column<LocalTime> column, int sourceRow)Sets the value at row to the value at sourceRow in the given column and return this columnTimeColumnset(Selection rowSelection, LocalTime newValue)Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteriaTimeColumnsetMissing(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)intsize()Returns the number of elements in this column, including missing valuesvoidsortAscending()Sorts my values in ascending ordervoidsortDescending()Sorts my values in descending orderTimeColumnsubset(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<LocalTime>top(int n)Returns the largest ("top") n values in the column.StringtoString()TimeColumnunique()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(int i)TimeColumnwhere(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:
appendMissingin 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:
subsetin interfaceColumn<LocalTime>- Overrides:
subsetin 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:
lagin interfaceColumn<LocalTime>- Specified by:
lagin 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:
removeMissingin 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:
getUnformattedStringin 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:
emptyCopyin interfaceColumn<LocalTime>- Specified by:
emptyCopyin 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:
sortAscendingin interfaceColumn<LocalTime>
-
sortDescending
public void sortDescending()
Sorts my values in descending order- Specified by:
sortDescendingin interfaceColumn<LocalTime>
-
max
public LocalTime max()
-
min
public LocalTime min()
- Specified by:
minin 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:
countMissingin interfaceColumn<LocalTime>- Returns:
- missing values as int
-
countUnique
public int countUnique()
Returns the count of unique values in this column.- Specified by:
countUniquein 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:
appendCellin 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:
appendCellin interfaceColumn<LocalTime>
-
getIntInternal
public int getIntInternal(int index)
Returns the packed time representation of the value at index- Specified by:
getIntInternalin interfaceTimeFilters- Specified by:
getIntInternalin interfaceTimeMapFunctions
-
getPackedTime
protected int getPackedTime(int index)
-
get
public LocalTime get(int index)
Returns the value at the given zero-based index- Specified by:
getin interfaceColumn<LocalTime>- Specified by:
getin interfaceTimeFilters- Specified by:
getin interfaceTimeMapFunctions
-
rowComparator
public it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
Returns an IntComparator for sorting my rows- Specified by:
rowComparatorin interfaceColumn<LocalTime>
-
getDouble
public double getDouble(int i)
-
asDoubleArray
public double[] asDoubleArray()
-
asDoubleColumn
public DoubleColumn asDoubleColumn()
-
toString
public String toString()
- Overrides:
toStringin 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:
setin interfaceColumn<LocalTime>- Overrides:
setin classAbstractColumn<TimeColumn,LocalTime>
-
intIterator
public it.unimi.dsi.fastutil.ints.IntIterator intIterator()
-
contains
public boolean contains(LocalTime time)
Returnstrueif 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:ColumnReturns 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:
setMissingin 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:
isNotMissingin 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:
wherein interfaceColumn<LocalTime>- Specified by:
wherein interfaceTimeFilters
-
asObjectArray
public LocalTime[] asObjectArray()
Description copied from interface:ColumnReturns an array of objects as appropriate for my type of column- Specified by:
asObjectArrayin interfaceColumn<LocalTime>
-
fillWith
public TimeColumn fillWith(Iterator<LocalTime> iterator)
- Specified by:
fillWithin interfaceTimeFillers<TimeColumn>
-
fillWith
public TimeColumn fillWith(Iterable<LocalTime> iterable)
- Specified by:
fillWithin interfaceTimeFillers<TimeColumn>
-
fillWith
public TimeColumn fillWith(Supplier<LocalTime> supplier)
- Specified by:
fillWithin interfaceTimeFillers<TimeColumn>
-
compare
public int compare(LocalTime o1, LocalTime o2)
- Specified by:
comparein interfaceComparator<LocalTime>
-
-