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 and 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(Column<T> column) |
Column<T> |
append(Column<T> column,
int row) |
Column<T> |
append(T value) |
Column<T> |
appendCell(String stringValue) |
Column<T> |
appendCell(String stringValue,
AbstractColumnParser<?> parser) |
Column<T> |
appendMissing()
Appends a missing value appropriate to the column
|
Column<T> |
appendObj(Object value) |
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
Note, if a value in the column is missing, a
null is added in it's place |
T[] |
asObjectArray() |
StringColumn |
asStringColumn() |
int |
byteSize()
Returns the width of a cell in this column, in bytes.
|
void |
clear() |
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
TODO override in column subtypes for performance |
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.
|
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) |
T |
get(int row) |
String |
getString(int row)
Returns a string representation of the value at the given row.
|
String |
getUnformattedString(int r) |
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
|
boolean |
isEmpty()
Returns true if the column has no data
|
Selection |
isMissing() |
boolean |
isMissing(int rowNumber) |
Selection |
isNotMissing() |
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) |
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 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> Column<R> |
mapInto(Function<? super T,? extends R> fun,
Column<R> into)
Maps the function across all rows, appending the results to the provided Column
|
default Column<T> |
max(Column<T> other)
Returns a column containing the element-wise min between this column and other column
TODO(lwhite) Override in column subtypes for better performance
|
default Optional<T> |
max(Comparator<? super T> comp)
Returns the maximum row 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
TODO(lwhite) Override in column subtypes for better performance
|
default Optional<T> |
min(Comparator<? super T> comp)
Returns the minimum row according to the provided Comparator
|
String |
name()
Returns the column's name.
|
default boolean |
noneMatch(Predicate<? super T> test)
Returns true if no row satisfies the predicate, false otherwise
|
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() |
default RollingColumn |
rolling(int windowSize) |
it.unimi.dsi.fastutil.ints.IntComparator |
rowComparator() |
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.
|
Column<T> |
set(int row,
Column<T> sourceColumn,
int sourceRow) |
Column<T> |
set(int row,
T value) |
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 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
|
Column<T> |
setMissing(int i) |
Column<T> |
setName(String name)
Sets the columns name to the given string
|
int |
size() |
void |
sortAscending() |
void |
sortDescending() |
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) |
Table |
summary() |
default String |
title() |
ColumnType |
type()
Returns this column's ColumnType
|
Column<T> |
unique()
Returns a column of the same type as the receiver, containing only the unique values of the receiver.
|
Column<T> |
where(Selection selection) |
forEach, iterator, spliterator
compare, comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
int size()
Table summary()
T[] asObjectArray()
int countMissing()
default int countUnique()
String name()
ColumnType type()
ColumnType
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)
String getUnformattedString(int r)
boolean isMissing(int rowNumber)
default String print()
default int columnWidth()
default List<T> asList()
null
is added in it's placedefault boolean contains(T object)
true
if the given object appears in this column, and false otherwise
TODO override in column subtypes for performancedefault 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
- default <R> Column<R> mapInto(Function<? super T,? extends R> fun, Column<R> into)
fun
- function to mapinto
- Column to which results are appendeddefault Column<T> filter(Predicate<? super T> test)
test
- the predicatedefault 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)
default Column<T> max(Column<T> other)
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, AbstractColumnParser<?> parser)
Column<T> unique()
Column
Column<T> setName(String name)
name
- The new name MUST be unique for any table containing this columndefault 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 sampleStringColumn asStringColumn()
Copyright © 2019. All rights reserved.