Package tech.tablesaw.columns
Class AbstractColumn<C extends Column<T>,T>
- java.lang.Object
-
- tech.tablesaw.columns.AbstractColumn<C,T>
-
- All Implemented Interfaces:
Iterable<T>
,Comparator<T>
,Column<T>
- Direct Known Subclasses:
BooleanColumn
,DateColumn
,DateTimeColumn
,InstantColumn
,NumberColumn
,StringColumn
,TimeColumn
public abstract class AbstractColumn<C extends Column<T>,T> extends Object implements Column<T>
Partial implementation of theColumn
interface
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ARRAY_SIZE
-
Constructor Summary
Constructors Constructor Description AbstractColumn(ColumnType type, String name, AbstractColumnParser<T> parser)
Constructs a column with the givenColumnType
, name, andAbstractColumnParser
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringColumn
asStringColumn()
Returns a StringColumn consisting of the (unformatted) String representation of this column valuesabstract Column<T>
emptyCopy()
Returns a copy of the receiver with no data.C
filter(Predicate<? super T> test)
Returns a new Column of the same type with only those rows satisfying the predicateC
first(int numRows)
Returns a column of the same type containing the firstnumRows
of this column.int
indexOf(Object o)
Returns the index of the first occurrence ofo
in the column or -1 if the element is not in the column.C
inRange(int start, int end)
Returns a column containing the rows in this column beginning with start inclusive, and ending with end exclusiveC
last(int numRows)
Returns a column of the same type containing the lastnumRows
of this column.int
lastIndexOf(Object o)
Returns the index of the last occurrence ofo
in the column or -1 if the element is not in the column.C
map(Function<? super T,? extends T> fun)
Maps the function across all rows, appending the results to a new Column of the same typeC
max(Column<T> other)
Returns a column containing the element-wise min between this column and other columnC
min(Column<T> other)
Returns a column containing the element-wise min between this column and other columnString
name()
Returns the column's name.AbstractColumnParser<T>
parser()
Returns the parser used byColumn.appendCell(String)
()}.C
sampleN(int n)
Returns a column containing a random sample of the values in this columnC
sampleX(double proportion)
Returns a table consisting of randomly selected values from this column.C
set(Selection rowSelection, T newValue)
Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteriaC
set(Selection condition, Column<T> other)
Updates this column where values matching the selection are replaced with the corresponding value from the given columnC
setName(String name)
Sets the columns name to the given stringC
setParser(AbstractColumnParser<T> parser)
Sets the parser used byColumn.appendCell(String)
C
sorted(Comparator<? super T> comp)
Returns a new Column of the same type sorted according to the provided ComparatorC
subset(int[] rows)
Return a column of the same type containing just those elements whose indexes are included in the given arrayString
toString()
ColumnType
type()
Returns this column's ColumnType-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface tech.tablesaw.columns.Column
allMatch, anyMatch, append, append, append, appendCell, appendCell, appendMissing, appendObj, asBytes, asList, asObjectArray, asSet, byteSize, clear, columnWidth, contains, copy, count, count, countMissing, countUnique, emptyCopy, equals, get, getString, getUnformattedString, interpolate, isEmpty, isMissing, isMissing, isNotMissing, lag, lead, map, mapInto, max, min, noneMatch, print, reduce, reduce, removeMissing, rolling, rowComparator, set, set, set, set, setMissing, setMissingTo, size, sortAscending, sortDescending, summary, title, unique, valueHash, where
-
Methods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Field Detail
-
DEFAULT_ARRAY_SIZE
public static final int DEFAULT_ARRAY_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractColumn
public AbstractColumn(ColumnType type, String name, AbstractColumnParser<T> parser)
Constructs a column with the givenColumnType
, name, andAbstractColumnParser
-
-
Method Detail
-
name
public String name()
Returns the column's name.
-
parser
public AbstractColumnParser<T> parser()
Returns the parser used byColumn.appendCell(String)
()}.
-
setParser
public C setParser(AbstractColumnParser<T> parser)
Sets the parser used byColumn.appendCell(String)
-
type
public ColumnType type()
Returns this column's ColumnType
-
emptyCopy
public abstract Column<T> emptyCopy()
Returns a copy of the receiver with no data. The column name and type are the same.
-
filter
public C filter(Predicate<? super T> test)
Returns a new Column of the same type with only those rows satisfying the predicate
-
sorted
public C sorted(Comparator<? super T> comp)
Returns a new Column of the same type sorted according to the provided Comparator
-
map
public C map(Function<? super T,? extends T> fun)
Maps the function across all rows, appending the results to a new Column of the same type
-
min
public C min(Column<T> other)
Returns a column containing the element-wise min between this column and other columnTODO(lwhite) Override in column subtypes for better performance
-
max
public C max(Column<T> other)
Returns a column containing the element-wise min between this column and other columnTODO(lwhite) Override in column subtypes for better performance
-
set
public C set(Selection condition, Column<T> other)
Updates this column where values matching the selection are replaced with the corresponding value from the given column
-
set
public C set(Selection rowSelection, T newValue)
Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteria
-
first
public C first(int numRows)
Returns a column of the same type containing the firstnumRows
of this column.
-
last
public C last(int numRows)
Returns a column of the same type containing the lastnumRows
of this column.
-
sampleN
public C sampleN(int n)
Returns a column containing a random sample of the values in this column
-
sampleX
public C sampleX(double proportion)
Returns a table consisting of randomly selected values from this column. The sample size is based on the given proportion of the total number of cells in this column
-
subset
public C subset(int[] rows)
Return a column of the same type containing just those elements whose indexes are included in the given array
-
inRange
public C inRange(int start, int end)
Returns a column containing the rows in this column beginning with start inclusive, and ending with end exclusive
-
asStringColumn
public StringColumn asStringColumn()
Returns a StringColumn consisting of the (unformatted) String representation of this column values- Specified by:
asStringColumn
in interfaceColumn<C extends Column<T>>
- Returns:
- a
StringColumn
built using the columnColumn.getUnformattedString(int)
method
-
indexOf
public int indexOf(Object o)
Returns the index of the first occurrence ofo
in the column or -1 if the element is not in the column.
-
-