public class Table extends Relation implements Iterable<Row>
Tables are the main data-type and primary focus of Airframe.
Modifier and Type | Class | Description |
---|---|---|
static class |
Table.RowPair |
Modifier | Constructor | Description |
---|---|---|
protected |
Table(String name,
Column... columns) |
Returns a new Table initialized with the given names and columns
|
Modifier and Type | Method | Description |
---|---|---|
Table |
addColumns(Column<?>... cols) |
Adds the given column to this table
|
void |
addRow(int rowIndex,
Table sourceTable) |
Adds a single row to this table from sourceTable, copying every column in sourceTable
|
void |
addRow(Row row) |
|
Table |
append(Table tableToAppend) |
|
List<CategoricalColumn<?>> |
categoricalColumns(String... columnNames) |
Returns only the columns whose names are given in the input array
|
void |
clear() |
Clears all the data from this table
|
Column<?> |
column(int columnIndex) |
Returns the column at the given index in the column list
|
Column[] |
columnArray() |
|
int |
columnCount() |
Returns the number of columns in the table
|
int |
columnIndex(String columnName) |
Returns the index of the column with the given name
|
int |
columnIndex(Column<?> column) |
Returns the index of the given column (its position in the list of columns)
|
List<String> |
columnNames() |
Returns a List of the names of all the columns in this table
|
List<Column<?>> |
columns() |
Returns the list of columns
|
Table |
concat(Table tableToConcatenate) |
Add all the columns of tableToConcatenate to this table
Note: The columns in the result must have unique names, when compared case insensitive
Note: Both tables must have the same number of rows
|
Table |
copy() |
Returns a table with the same columns as this table
|
Table |
countBy(CategoricalColumn<?> groupingColumn) |
Returns a table containing two columns, the grouping column, and a column named "Count" that contains
the counts for each grouping column value
|
static Table |
create(String tableName) |
Returns a new, empty table (without rows or columns) with the given name
|
static Table |
create(String tableName,
Column<?>... columns) |
Returns a new table with the given columns and given name
|
boolean |
detect(Predicate<Row> predicate) |
Applies the predicate to each row, and return true if any row returns true
|
void |
doWithRowPairs(Consumer<Table.RowPair> pairConsumer) |
Applies the function in
pairs to each consecutive pairs of rows in the table |
void |
doWithRows(Consumer<Row> doable) |
Applies the operation in
doable to every row in the table |
void |
doWithRows(tech.tablesaw.api.Table.Pairs pairs) |
Applies the function in
pairs to each consecutive pairs of rows in the table |
Table |
dropDuplicateRows() |
Returns the unique records in this table
Note: Uses a lot of memory for a sort
|
Table |
dropRange(int rowStart,
int rowEnd) |
|
Table |
dropRows(int... rowNumbers) |
|
Table |
dropRowsWithMissingValues() |
Returns only those records in this table that have no columns with missing values
|
Table |
dropWhere(Selection selection) |
|
Table |
emptyCopy() |
Returns a table with the same columns as this table, but no data
|
Table |
emptyCopy(int rowSize) |
Returns a table with the same columns as this table, but no data, initialized to the given row size
|
Table |
first(int nRows) |
Returns a new table containing the first
nrows of data in this table |
String |
get(int r,
int c) |
Returns a string representation of the value at the given row and column indexes
|
String |
get(int r,
String columnName) |
Returns a string representation of the value at the given row and column indexes
|
String |
getUnformatted(int r,
int c) |
Returns a string representation of the value at the given row and column indexes
|
Table |
inRange(int rowStart,
int rowEnd) |
|
Table |
insertColumn(int index,
Column<?> column) |
Adds the given column to this table at the given position in the column list
|
Iterator<Row> |
iterator() |
|
DataFrameJoiner |
join(String columnName) |
|
Table |
last(int nRows) |
Returns a new table containing the last
nrows of data in this table |
Table |
missingValueCounts() |
|
String |
name() |
Returns the name of the table
|
String |
printHtml() |
|
static DataFrameReader |
read() |
|
Table |
removeColumns(Column<?>... columns) |
Removes the given columns
|
Table |
removeColumnsWithMissingValues() |
Removes the given columns with missing values
|
Table |
replaceColumn(int colIndex,
Column<?> newColumn) |
Replaces an existing column (by index) in this table with the given new column
|
Table |
replaceColumn(String columnName,
Column<?> newColumn) |
Replaces an existing column (by name) in this table with the given new column
|
Table |
retainColumns(String... columnNames) |
Removes all columns except for those given in the argument from this table
|
Table |
retainColumns(Column<?>... columns) |
Removes all columns except for those given in the argument from this table
|
void |
rollWithRows(Consumer<Row[]> rowConsumer,
int n) |
Applies the function in
pairs to each group of contiguous rows of size n in the table
This can be used, for example, to calculate a running average of in rows |
int |
rowCount() |
Returns the number of rows in the table
|
Table |
rows(int... rowNumbers) |
|
Table |
sampleN(int nRows) |
Returns a table consisting of randomly selected records from this table
|
Table[] |
sampleSplit(double table1Proportion) |
Splits the table into two, randomly assigning records to each according to the proportion given in
trainingProportion
|
Table |
sampleX(double proportion) |
Returns a table consisting of randomly selected records from this table.
|
Table |
select(String... columnNames) |
|
Table |
select(Column<?>... columns) |
|
Table |
setName(String name) |
Sets the name of the table
|
Table |
sortAscendingOn(String... columnNames) |
Returns a copy of this table sorted in the order of the given column names, in ascending order
|
Table |
sortDescendingOn(String... columnNames) |
Returns a copy of this table sorted on the given column names, applied in order, descending
TODO: Provide equivalent methods naming columns by index
|
Table |
sortOn(int... columnIndexes) |
Sorts this table into a new table on the columns indexed in ascending order
|
Table |
sortOn(String... columnNames) |
Returns a copy of this table sorted on the given column names, applied in order,
|
Table |
sortOn(Comparator<Row> rowComparator) |
Returns a copy of this table sorted using the given comparator
|
Table |
sortOn(Sort key) |
|
TableSliceGroup |
splitOn(String... columns) |
Returns a non-overlapping and exhaustive collection of "slices" over this table.
|
TableSliceGroup |
splitOn(CategoricalColumn... columns) |
Returns a non-overlapping and exhaustive collection of "slices" over this table.
|
void |
stepWithRows(Consumer<Row[]> rowConsumer,
int n) |
Applies the operation in
doable to every row in the table |
Table |
structure() |
|
Summarizer |
summarize(String col1Name,
String col2Name,
String col3Name,
String col4Name,
AggregateFunction... functions) |
|
Summarizer |
summarize(String col1Name,
String col2Name,
String col3Name,
AggregateFunction... functions) |
|
Summarizer |
summarize(String numericColumn1Name,
String numericColumn2Name,
AggregateFunction... functions) |
|
Summarizer |
summarize(String columName,
AggregateFunction... functions) |
|
Summarizer |
summarize(List<String> columnNames,
AggregateFunction... functions) |
|
Summarizer |
summarize(Column<?> column1,
Column<?> column2,
AggregateFunction... function) |
|
Summarizer |
summarize(Column<?> column1,
Column<?> column2,
Column<?> column3,
AggregateFunction... function) |
|
Summarizer |
summarize(Column<?> column1,
Column<?> column2,
Column<?> column3,
Column<?> column4,
AggregateFunction... function) |
|
Summarizer |
summarize(Column numberColumn,
AggregateFunction... function) |
|
Table |
where(Selection selection) |
|
DataFrameWriter |
write() |
|
Table |
xTabColumnPercents(String column1Name,
String column2Name) |
|
Table |
xTabCounts(String column1Name) |
Returns a table with two columns, the first contains a value each unique value in the argument,
and the second contains the number of observations of each value
|
Table |
xTabCounts(String column1Name,
String column2Name) |
Returns a table with n by m + 1 cells.
|
Table |
xTabPercents(String column1Name) |
Returns a table with two columns, the first contains a value each unique value in the argument,
and the second contains the proportion of observations having that value
|
Table |
xTabRowPercents(String column1Name,
String column2Name) |
|
Table |
xTabTablePercents(String column1Name,
String column2Name) |
Returns a table with n by m + 1 cells.
|
forEach, spliterator
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
as, booleanColumn, booleanColumn, booleanColumns, categoricalColumn, categoricalColumn, column, columns, columns, columnsOfType, columnTypes, colWidths, containsColumn, dateColumn, dateColumn, dateColumns, dateTimeColumn, dateTimeColumn, dateTimeColumns, doubleColumn, doubleColumn, doubleColumns, isEmpty, nCol, nCol, numberColumn, numberColumn, numberColumns, print, print, printAll, removeColumns, removeColumns, shape, stringColumn, stringColumn, stringColumns, summary, timeColumn, timeColumn, timeColumns, toString
public static Table create(String tableName)
public static Table create(String tableName, Column<?>... columns)
columns
- One or more columns, all of the same @code{column.size()}public static DataFrameReader read()
public DataFrameWriter write()
public Table addColumns(Column<?>... cols)
addColumns
in class Relation
public Table insertColumn(int index, Column<?> column)
index
- Zero-based index into the column listcolumn
- Column to be addedpublic Table replaceColumn(int colIndex, Column<?> newColumn)
colIndex
- Zero-based index of the column to be replacednewColumn
- Column to be addedpublic Table replaceColumn(String columnName, Column<?> newColumn)
columnName
- String name of the column to be replacednewColumn
- Column to be addedpublic Column<?> column(int columnIndex)
public int columnCount()
columnCount
in class Relation
public int rowCount()
public Column[] columnArray()
public List<CategoricalColumn<?>> categoricalColumns(String... columnNames)
public int columnIndex(String columnName)
columnIndex
in class Relation
IllegalArgumentException
- if the input string is not the name of any column in the tablepublic int columnIndex(Column<?> column)
columnIndex
in class Relation
IllegalArgumentException
- if the column is not present in this tablepublic List<String> columnNames()
columnNames
in class Relation
public String get(int r, int c)
public String getUnformatted(int r, int c)
getUnformatted
in class Relation
r
- the row index, 0 basedc
- the column index, 0 basedpublic String get(int r, String columnName)
r
- the row index, 0 basedcolumnName
- the name of the column to be returned
// TODO: performance would be enhanced if columns could be referenced via a hashTable
public Table copy()
public Table emptyCopy()
public Table emptyCopy(int rowSize)
public Table[] sampleSplit(double table1Proportion)
table1Proportion
- The proportion to go in the first tablepublic Table sampleX(double proportion)
proportion
- The proportion to go in the samplepublic Table sampleN(int nRows)
nRows
- The number of rows to go in the samplepublic void clear()
public Table first(int nRows)
nrows
of data in this tablepublic Table last(int nRows)
nrows
of data in this tablepublic Table sortOn(int... columnIndexes)
TODO(lwhite): Rework this so passing an negative number does a descending sort
public Table sortOn(String... columnNames)
if column name starts with - then sort that column descending otherwise sort ascending
public Table sortAscendingOn(String... columnNames)
public Table sortDescendingOn(String... columnNames)
public Table sortOn(Comparator<Row> rowComparator)
public void addRow(int rowIndex, Table sourceTable)
rowIndex
- The row in sourceTable to add to this tablesourceTable
- A table with the same column structure as this tablepublic void addRow(Row row)
public Table rows(int... rowNumbers)
public Table dropRows(int... rowNumbers)
public Table inRange(int rowStart, int rowEnd)
public Table dropRange(int rowStart, int rowEnd)
public TableSliceGroup splitOn(String... columns)
public TableSliceGroup splitOn(CategoricalColumn... columns)
public String printHtml()
public Table dropDuplicateRows()
public Table dropRowsWithMissingValues()
public Table removeColumns(Column<?>... columns)
removeColumns
in class Relation
public Table removeColumnsWithMissingValues()
public Table retainColumns(Column<?>... columns)
public Table retainColumns(String... columnNames)
public Table concat(Table tableToConcatenate)
tableToConcatenate
- The table containing the columns to be addedpublic Summarizer summarize(String columName, AggregateFunction... functions)
public Summarizer summarize(List<String> columnNames, AggregateFunction... functions)
public Summarizer summarize(String numericColumn1Name, String numericColumn2Name, AggregateFunction... functions)
public Summarizer summarize(String col1Name, String col2Name, String col3Name, AggregateFunction... functions)
public Summarizer summarize(String col1Name, String col2Name, String col3Name, String col4Name, AggregateFunction... functions)
public Summarizer summarize(Column numberColumn, AggregateFunction... function)
public Summarizer summarize(Column<?> column1, Column<?> column2, AggregateFunction... function)
public Summarizer summarize(Column<?> column1, Column<?> column2, Column<?> column3, AggregateFunction... function)
public Summarizer summarize(Column<?> column1, Column<?> column2, Column<?> column3, Column<?> column4, AggregateFunction... function)
public Table xTabCounts(String column1Name, String column2Name)
public Table xTabTablePercents(String column1Name, String column2Name)
public Table xTabPercents(String column1Name)
public Table xTabCounts(String column1Name)
public Table countBy(CategoricalColumn<?> groupingColumn)
public DataFrameJoiner join(String columnName)
public Table missingValueCounts()
public void doWithRows(Consumer<Row> doable)
doable
to every row in the tablepublic boolean detect(Predicate<Row> predicate)
public void stepWithRows(Consumer<Row[]> rowConsumer, int n)
doable
to every row in the tablepublic void doWithRows(tech.tablesaw.api.Table.Pairs pairs)
pairs
to each consecutive pairs of rows in the tablepublic void doWithRowPairs(Consumer<Table.RowPair> pairConsumer)
pairs
to each consecutive pairs of rows in the tableCopyright © 2018. All rights reserved.