Comparator<T>
, Iterable<T>
BooleanMapUtils
, CategoricalColumn<T>
, DateFilters
, DateMapFunctions
, DateTimeFilters
, DateTimeMapFunctions
, InstantMapFunctions
, NumericColumn<T>
, StringFilters
, StringMapFunctions
, StringReduceUtils
, TemporalColumn<T>
, TemporalFilters<T>
, TemporalMapFunctions<T>
, TimeFilters
, TimeMapFunctions
AbstractColumn
, AbstractStringColumn
, BooleanColumn
, DateColumn
, DateTimeColumn
, DoubleColumn
, FloatColumn
, InstantColumn
, IntColumn
, LongColumn
, NumberColumn
, ShortColumn
, StringColumn
, TextColumn
, TimeColumn
public interface Column<T> extends Iterable<T>, Comparator<T>
Columns can either exist on their own or be a part of a table. All the data in a single column is of a particular type.
Modifier and Type | Method | Description |
---|---|---|
default boolean |
allMatch(Predicate<? super T> test) |
Returns true if all rows satisfy the predicate, false otherwise
|
default boolean |
anyMatch(Predicate<? super T> test) |
Returns true if any row satisfies the predicate, false otherwise
|
Column<T> |
append(T value) |
Appends value to the bottom of this column and return this column
|
Column<T> |
append(Column<T> column) |
Appends all the values in the argument to the bottom of this column and return this column
|
Column<T> |
append(Column<T> column,
int row) |
Appends the value at the given row in the given column to the bottom of this column and return
this column
|
Column<T> |
appendCell(String stringValue) |
Add one element to the bottom of this column and set its value to the parsed value of the given
String.
|
Column<T> |
appendCell(String stringValue,
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
|
Column<T> |
appendMissing() |
Appends a missing value appropriate to the column
|
Column<T> |
appendObj(Object value) |
Appends the given value to the bottom of this column and return this column
|
byte[] |
asBytes(int rowNumber) |
Returns the contents of the cell at rowNumber as a byte[].
|
default List<T> |
asList() |
Returns a list of all the elements in this column
|
T[] |
asObjectArray() |
Returns an array of objects as appropriate for my type of column
|
Set<T> |
asSet() |
Returns a Set containing all the unique values in this column
|
StringColumn |
asStringColumn() |
Returns a StringColumn consisting of the (unformatted) String representation of this column
values
|
int |
byteSize() |
Returns the width of a cell in this column, in bytes.
|
void |
clear() |
Removes all elements TODO: Make this return this column
|
default int |
columnWidth() |
Returns the width of the column in characters, for printing
|
default boolean |
contains(T object) |
Returns
true if the given object appears in this column, and false otherwise |
Column<T> |
copy() |
Returns a deep copy of the receiver
|
default int |
count(Predicate<? super T> test) |
Counts the number of rows satisfying predicate
|
default int |
count(Predicate<? super T> test,
int max) |
Counts the number of rows satisfying predicate, but only upto the max value
|
int |
countMissing() |
Returns the count of missing values in this column.
|
default int |
countUnique() |
Returns the count of unique values in this column.
|
Column<T> |
emptyCopy() |
Returns a copy of the receiver with no data.
|
Column<T> |
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 rowNumber2
|
default Column<T> |
filter(Predicate<? super T> test) |
Returns a new Column of the same type with only those rows satisfying the predicate
|
default Column<T> |
first(int numRows) |
Returns a column of the same type containing the first
numRows of this column. |
T |
get(int row) |
Returns the value at the given zero-based index
|
String |
getString(int row) |
Returns a string representation of the value at the given row.
|
String |
getUnformattedString(int r) |
Returns a String representation of the value at index r, without any formatting applied
|
int |
indexOf(Object o) |
Returns the index of the first occurrence of
o in the column or -1 if the element is
not in the column. |
default Column<T> |
inRange(int start,
int end) |
Returns a column containing the rows in this column beginning with start inclusive, and ending
with end exclusive
|
default Interpolator<T> |
interpolate() |
Provides the ability to create a new column with missing cells filled based off the value of
nearby cells.
|
boolean |
isEmpty() |
Returns true if the column has no data
|
Selection |
isMissing() |
Returns a selection containing an index for every missing value in this column
|
boolean |
isMissing(int rowNumber) |
Returns true if the value at rowNumber is missing
|
Selection |
isNotMissing() |
Returns a selection containing an index for every non-missing value in this column
|
Column<T> |
lag(int n) |
Returns a column of the same type and size as the receiver, containing the receivers values
offset by n.
|
default Column<T> |
last(int numRows) |
Returns a column of the same type containing the last
numRows of this column. |
default Column<T> |
lead(int n) |
Returns a column of the same type as the receiver, containing the receivers values offset -n
For example if you lead a column containing 2, 3, 4 by 1, you get a column containing 3, 4, NA.
|
default <R,C extends Column<R>> |
map(Function<? super T,? extends R> fun,
Function<String,C> creator) |
Maps the function across all rows, appending the results to the created Column.
|
default Column<T> |
map(Function<? super T,? extends T> fun) |
Maps the function across all rows, appending the results to a new Column of the same type
|
default <R,C extends Column<R>> |
mapInto(Function<? super T,? extends R> fun,
C into) |
Maps the function across all rows, storing the results into the provided Column.
|
default Optional<T> |
max(Comparator<? super T> comp) |
Returns the maximum row according to the provided Comparator
|
default Column<T> |
max(Column<T> other) |
Returns a column containing the element-wise min between this column and other column
|
default Optional<T> |
min(Comparator<? super T> comp) |
Returns the minimum value according to the provided Comparator
|
default Column<T> |
min(Column<T> other) |
Returns a column containing the element-wise min between this column and other column
|
String |
name() |
Returns the column's name.
|
default boolean |
noneMatch(Predicate<? super T> test) |
Returns true if no row satisfies the predicate, false otherwise
|
AbstractColumnParser<T> |
parser() |
Returns the parser used by
appendCell(String) ()}. |
default String |
print() |
TODO(lwhite): Print n from the top and bottom, like a table;
|
default Optional<T> |
reduce(BinaryOperator<T> op) |
Reduction with binary operator
|
default T |
reduce(T initial,
BinaryOperator<T> op) |
Reduction with binary operator and initial value
|
Column<T> |
removeMissing() |
Returns a copy of this column with the missing values removed
|
default RollingColumn |
rolling(int windowSize) |
Returns a
RollingColumn with the given windowSize, which can be used for performing
calculations on rolling subsets of my data |
it.unimi.dsi.fastutil.ints.IntComparator |
rowComparator() |
Returns an IntComparator for sorting my rows
|
default Column<T> |
sampleN(int n) |
Returns a column containing a random sample of the values in this column
|
default Column<T> |
sampleX(double proportion) |
Returns a table consisting of randomly selected values from this column.
|
default Column<T> |
set(int row,
String stringValue,
AbstractColumnParser<?> parser) |
Sets the value at row to the parsed value of the given String using the given parser and
returns this column
|
Column<T> |
set(int row,
T value) |
Sets the value at index row to the given value and return this column
|
Column<T> |
set(int row,
Column<T> sourceColumn,
int sourceRow) |
Sets the value at row to the value at sourceRow in the given column and return this column
|
default Column<T> |
set(Predicate<T> condition,
Column<T> other) |
Updates this column where values matching the selection are replaced with the corresponding
value from the given column
|
default Column<T> |
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
|
default Column<T> |
set(Selection condition,
Column<T> other) |
Updates this column where values matching the selection are replaced with the corresponding
value from the given column
|
Column<T> |
setMissing(int i) |
Sets the value at index i to the missing-value indicator for this column type, and return this
column
|
default Column<T> |
setMissingTo(T newValue) |
Sets the value of any missing data in the column to newValue and returns the same column
|
Column<T> |
setName(String name) |
Sets the columns name to the given string
|
Column<T> |
setParser(AbstractColumnParser<T> parser) |
Sets the parser used by
appendCell(String) |
int |
size() |
Returns the number of elements in this column, including missing values
|
void |
sortAscending() |
Sorts my values in ascending order
|
void |
sortDescending() |
Sorts my values in descending order
|
default Column<T> |
sorted(Comparator<? super T> comp) |
Returns a new Column of the same type sorted according to the provided Comparator
|
default Column<T> |
subset(int[] rows) |
Return a column of the same type containing just those elements whose indexes are included in
the given array
|
Table |
summary() |
Returns a table containing a ColumnType specific summary of the data in this column
|
default String |
title() |
|
ColumnType |
type() |
Returns this column's ColumnType
|
Column<T> |
unique() |
Returns a column of the same type containing only the unique values
|
int |
valueHash(int rowNumber) |
Returns an int suitable as a hash for the value in this column at the given index
|
Column<T> |
where(Selection selection) |
Returns a new column containing the subset referenced by the
Selection |
compare, comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
forEach, iterator, spliterator
int size()
Table summary()
T[] asObjectArray()
int countMissing()
default int countUnique()
String name()
ColumnType type()
ColumnType
AbstractColumnParser<T> parser()
appendCell(String)
()}.AbstractColumnParser
String getString(int row)
row
- The index of the row.T get(int row)
default T reduce(T initial, BinaryOperator<T> op)
initial
- initial valueop
- the operatordefault Optional<T> reduce(BinaryOperator<T> op)
op
- the operatorvoid clear()
void sortAscending()
void sortDescending()
boolean isEmpty()
it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
default String title()
Selection isMissing()
Selection isNotMissing()
int byteSize()
byte[] asBytes(int rowNumber)
rowNumber
- index of the rowdefault RollingColumn rolling(int windowSize)
RollingColumn
with the given windowSize, which can be used for performing
calculations on rolling subsets of my datawindowSize
- The number of elements to include in each calculationString getUnformattedString(int r)
boolean isMissing(int rowNumber)
default String print()
default int columnWidth()
default List<T> asList()
Note, if a value in the column is missing, a null
is added in it's place
default boolean contains(T object)
true
if the given object appears in this column, and false otherwise
TODO override in column subtypes for performance
default int count(Predicate<? super T> test, int max)
test
- the predicatemax
- the maximum number of rows to countdefault int count(Predicate<? super T> test)
test
- the predicatedefault boolean allMatch(Predicate<? super T> test)
test
- the predicatedefault boolean anyMatch(Predicate<? super T> test)
test
- the predicatedefault boolean noneMatch(Predicate<? super T> test)
test
- the predicatedefault Optional<T> max(Comparator<? super T> comp)
comp
- default Optional<T> min(Comparator<? super T> comp)
comp
- the Comparator to usedefault <R,C extends Column<R>> C mapInto(Function<? super T,? extends R> fun, C into)
The target column must have at least the same number of rows.
fun
- function to mapinto
- Column into which results are setdefault <R,C extends Column<R>> C map(Function<? super T,? extends R> fun, Function<String,C> creator)
Example:
DoubleColumn d; StringColumn s = d.map(String::valueOf, StringColumn::create);
fun
- function to mapcreator
- the creator of the Column. Its String argument will be the name of the current
column (see name()
)Column<T> setMissing(int i)
default Column<T> setMissingTo(T newValue)
newValue
- the value to be used for all missing data in this columndefault Column<T> filter(Predicate<? super T> test)
test
- the predicatedefault Column<T> subset(int[] rows)
default Column<T> sorted(Comparator<? super T> comp)
comp
- the ComparatorColumn<T> emptyCopy()
Column
Column<T> emptyCopy(int rowSize)
rowSize
- the initial row sizeColumn
default Column<T> map(Function<? super T,? extends T> fun)
fun
- function to mapdefault Column<T> min(Column<T> other)
TODO(lwhite) Override in column subtypes for better performance
default Column<T> max(Column<T> other)
TODO(lwhite) Override in column subtypes for better performance
default Column<T> set(Predicate<T> condition, Column<T> other)
default Column<T> set(Selection condition, Column<T> other)
default Column<T> lead(int n)
default Column<T> set(Selection rowSelection, T newValue)
Column<T> lag(int n)
For example if you lag a column containing 2, 3, 4 by 1, you get a column containing NA, 2, 3
Column<T> appendCell(String stringValue)
Column<T> appendCell(String stringValue, AbstractColumnParser<?> parser)
Column<T> set(int row, T value)
default Column<T> set(int row, String stringValue, AbstractColumnParser<?> parser)
Column<T> set(int row, Column<T> sourceColumn, int sourceRow)
Column<T> append(Column<T> column)
Column<T> append(Column<T> column, int row)
Column<T> appendObj(Object value)
int valueHash(int rowNumber)
boolean equals(int rowNumber1, int rowNumber2)
Column<T> where(Selection selection)
Selection
Column<T> removeMissing()
Column<T> unique()
Column
default Column<T> first(int numRows)
numRows
of this column.default Column<T> last(int numRows)
numRows
of this column.Column<T> setName(String name)
name
- The new name MUST be unique for any table containing this columnColumn<T> setParser(AbstractColumnParser<T> parser)
appendCell(String)
parser
- a column parser that converts text input to the column data typedefault Column<T> inRange(int start, int end)
default Column<T> sampleN(int n)
n
- the number of values to selectdefault Column<T> sampleX(double proportion)
proportion
- The proportion to go in the sampledefault Interpolator<T> interpolate()
StringColumn asStringColumn()
StringColumn
built using the column getUnformattedString(int)
methodint indexOf(Object o)
o
in the column or -1 if the element is
not in the column.Copyright © 2022. All rights reserved.