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 theColumninterface
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_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 StringColumnasStringColumn()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.Cfilter(Predicate<? super T> test)Returns a new Column of the same type with only those rows satisfying the predicateCfirst(int numRows)Returns a column of the same type containing the firstnumRowsof this column.intindexOf(Object o)Returns the index of the first occurrence ofoin the column or -1 if the element is not in the column.CinRange(int start, int end)Returns a column containing the rows in this column beginning with start inclusive, and ending with end exclusiveClast(int numRows)Returns a column of the same type containing the lastnumRowsof this column.intlastIndexOf(Object o)Returns the index of the last occurrence ofoin the column or -1 if the element is not in the column.Cmap(Function<? super T,? extends T> fun)Maps the function across all rows, appending the results to a new Column of the same typeCmax(Column<T> other)Returns a column containing the element-wise min between this column and other columnCmin(Column<T> other)Returns a column containing the element-wise min between this column and other columnStringname()Returns the column's name.AbstractColumnParser<T>parser()Returns the parser used byColumn.appendCell(String)()}.CsampleN(int n)Returns a column containing a random sample of the values in this columnCsampleX(double proportion)Returns a table consisting of randomly selected values from this column.Cset(Selection rowSelection, T newValue)Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteriaCset(Selection condition, Column<T> other)Updates this column where values matching the selection are replaced with the corresponding value from the given columnCsetName(String name)Sets the columns name to the given stringCsetParser(AbstractColumnParser<T> parser)Sets the parser used byColumn.appendCell(String)Csorted(Comparator<? super T> comp)Returns a new Column of the same type sorted according to the provided ComparatorCsubset(int[] rows)Return a column of the same type containing just those elements whose indexes are included in the given arrayStringtoString()ColumnTypetype()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 firstnumRowsof this column.
-
last
public C last(int numRows)
Returns a column of the same type containing the lastnumRowsof 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:
asStringColumnin interfaceColumn<C extends Column<T>>- Returns:
- a
StringColumnbuilt using the columnColumn.getUnformattedString(int)method
-
indexOf
public int indexOf(Object o)
Returns the index of the first occurrence ofoin the column or -1 if the element is not in the column.
-
-