public class Table extends Relation implements Iterable<Row>
Tables are the main data-type and primary focus of Tablesaw.
Modifier and Type | Class | Description |
---|---|---|
static class |
Table.RowPair |
Deprecated.
|
Modifier and Type | Field | Description |
---|---|---|
static ReaderRegistry |
defaultReaderRegistry |
|
static WriterRegistry |
defaultWriterRegistry |
|
static String |
MELT_VALUE_COLUMN_NAME |
|
static String |
MELT_VARIABLE_COLUMN_NAME |
Modifier | Constructor | Description |
---|---|---|
protected |
Table(String name,
Collection<Column<?>> columns) |
Returns a new Table initialized with the given names and columns
|
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) |
Deprecated.
Use
append(Row) instead. |
Table |
append(Row row) |
Appends the given row to this table and returns the table.
|
Table |
append(Relation tableToAppend) |
Returns this table after adding the data from the argument
|
Row |
appendRow() |
Appends an empty row and returns a Row object indexed to the newly added row so values can be
set.
|
Table |
cast() |
Cast implements the 'tidy' cast operation as described in these papers by Hadley Wickham:
|
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() |
Returns the columns in this table as an array
|
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(String... categoricalColumnNames) |
Returns a table containing a column for each grouping column, and a column named "Count" that
contains the counts for each combination of grouping column values
|
Table |
countBy(CategoricalColumn<?>... groupingColumns) |
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() |
Returns a new, empty table (without rows or columns)
|
static Table |
create(String tableName) |
Returns a new, empty table (without rows or columns) with the given name
|
static Table |
create(String name,
Collection<Column<?>> columns) |
Returns a new table with the given columns and given name
|
static Table |
create(String name,
Stream<Column<?>> columns) |
Returns a new table with the given columns and given name
|
static Table |
create(String name,
Column<?>... columns) |
Returns a new table with the given columns and given name
|
static Table |
create(Collection<Column<?>> columns) |
Returns a new table with the given columns
|
static Table |
create(Stream<Column<?>> columns) |
Returns a new table with the given columns
|
static Table |
create(Column<?>... columns) |
Returns a new table with the given columns
|
boolean |
detect(Predicate<Row> predicate) |
Deprecated.
use
stream().anyMatch |
void |
doWithRowPairs(Consumer<Table.RowPair> pairConsumer) |
Deprecated.
use stream(2).forEach(rowConsumer)
|
void |
doWithRows(Consumer<Row> doable) |
Deprecated.
use
stream().forEach |
void |
doWithRows(tech.tablesaw.api.Table.Pairs pairs) |
Deprecated.
use stream(2).forEach(rowConsumer)
|
Table |
dropDuplicateRows() |
Returns the unique records in this table Note: Uses a lot of memory for a sort
|
Table |
dropRange(int rowCount) |
Returns a new table EXCLUDING the first rowCount rows if rowCount positive.
|
Table |
dropRange(int rowStart,
int rowEnd) |
Returns a table EXCLUDING the rows contained in the range from rowStart inclusive to rowEnd
exclusive
|
Table |
dropRows(int... rowNumbers) |
Returns a table EXCLUDING the rows contained in the given array of row indices
|
Table |
dropRowsWithMissingValues() |
Returns only those records in this table that have no columns with missing values
|
Table |
dropWhere(Function<Table,Selection> selection) |
Returns a new Table made by EXCLUDING any rows returned when the given function is applied to
this table
|
Table |
dropWhere(Selection selection) |
Returns a table EXCLUDING the rows contained in the given 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 |
Table |
inRange(int rowCount) |
Returns a new table containing the first rowCount rows if rowCount positive.
|
Table |
inRange(int rowStart,
int rowEnd) |
Returns a new table containing the rows contained in the range from rowStart inclusive to
rowEnd exclusive
|
Table |
insertColumn(int index,
Column<?> column) |
Adds the given column to this table at the given position in the column list
|
void |
internalAddWithoutValidation(Column<?> c) |
For internal Tablesaw use only
|
Iterator<Row> |
iterator() |
|
DataFrameJoiner |
joinOn(String... columnNames) |
Returns a new DataFrameJoiner initialized with multiple
columnNames |
Table |
last(int nRows) |
Returns a new table containing the last
nrows of data in this table |
Table |
melt(List<String> idVariables,
List<NumericColumn<?>> measuredVariables,
Boolean dropMissing) |
Melt implements the 'tidy' melt operation as described in these papers by Hadley Wickham.
|
Table |
missingValueCounts() |
Returns a table containing the number of missing values in each column in this table
|
String |
name() |
Returns the name of the table
|
Table |
pivot(String column1Name,
String column2Name,
String column3Name,
AggregateFunction<?,?> aggregateFunction) |
Returns a pivot on this table, where: The first column contains unique values from the index
column1 There are n additional columns, one for each unique value in column2 The values in each
of the cells in these new columns are the result of applying the given AggregateFunction to the
data in column3, grouped by the values of column1 and column2
|
Table |
pivot(CategoricalColumn<?> column1,
CategoricalColumn<?> column2,
NumericColumn<?> column3,
AggregateFunction<?,?> aggregateFunction) |
Returns a pivot on this table, where: The first column contains unique values from the index
column1 There are n additional columns, one for each unique value in column2 The values in each
of the cells in these new columns are the result of applying the given AggregateFunction to the
data in column3, grouped by the values of column1 and column2
|
static DataFrameReader |
read() |
Returns an object that an be used to read data from a file into a new Table
|
Table |
rejectColumns(int... columnIndexes) |
Returns a new table containing copies of all the columns from this table, except those at the
given indexes
|
Table |
rejectColumns(String... columnNames) |
Returns a new table containing copies of all the columns from this table, except those named in
the argument
|
Table |
rejectColumns(Column<?>... columns) |
Returns a new table containing copies of all the columns from this table, except those named in
the argument
|
Table |
removeColumns(int... columnIndexes) |
Removes the columns at the given indices from this table and returns this table
|
Table |
removeColumns(String... columns) |
Removes the columns with the given names from this table and returns this table
|
Table |
removeColumns(Column<?>... columns) |
Removes the given columns from this table and returns this table
|
Table |
removeColumnsWithMissingValues() |
Removes all columns with missing values from this table, and returns this table.
|
Table |
reorderColumns(String... columnNames) |
Return a new table (shallow copy) that contains all the columns in this table, in the order
given in the argument.
|
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 |
replaceColumn(Column<?> newColumn) |
Replaces an existing column having the same name of the given column with the given column
|
Table |
retainColumns(int... columnIndexes) |
Removes all columns except for those given in the argument from this table and returns this
table
|
Table |
retainColumns(String... columnNames) |
Removes all columns except for those given in the argument from this table and returns this
table
|
Table |
retainColumns(Column<?>... columns) |
Removes all columns except for those given in the argument from this table and returns this
table
|
Iterator<Row[]> |
rollingIterator(int n) |
Iterates over rolling sets of rows.
|
Stream<Row[]> |
rollingStream(int n) |
Streams over rolling sets of rows.
|
void |
rollWithRows(Consumer<Row[]> rowConsumer,
int n) |
Deprecated.
use stream(n).forEach(rowConsumer)
|
Row |
row(int rowIndex) |
Returns a new Row object with its position set to the given zero-based row index.
|
int |
rowCount() |
Returns the number of rows in the table
|
Table |
rows(int... rowNumbers) |
Returns a table containing the rows contained in the given array of row indices
|
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) |
Deprecated.
Use
selectColumns(String[]) instead |
Table |
select(Column<?>... columns) |
Deprecated.
Use
selectColumns(Column[]) instead |
Table |
selectColumns(int... columnIndexes) |
Returns a new table containing copies of the columns at the given indexes
|
Table |
selectColumns(String... columnNames) |
Returns a new table containing copies of the selected columns from this table
|
Table |
selectColumns(Column<?>... columns) |
Returns a new table containing copies of the selected columns from this table
|
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
|
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) |
Returns a copy of this table sorted using the given 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.
|
Iterator<Row[]> |
steppingIterator(int n) |
Streams over stepped sets of rows.
|
Stream<Row[]> |
steppingStream(int n) |
Streams over stepped sets of rows.
|
void |
stepWithRows(Consumer<Row[]> rowConsumer,
int n) |
Deprecated.
use steppingStream(n).forEach(rowConsumer)
|
Table[] |
stratifiedSampleSplit(CategoricalColumn<?> column,
double table1Proportion) |
Splits the table into two stratified samples, this uses the specified column to divide the
table into groups, randomly assigning records to each according to the proportion given in
trainingProportion.
|
Stream<Row> |
stream() |
Returns the rows in this table as a Stream
|
Summarizer |
summarize(String col1Name,
String col2Name,
String col3Name,
String col4Name,
AggregateFunction<?,?>... functions) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Summarizer |
summarize(String col1Name,
String col2Name,
String col3Name,
AggregateFunction<?,?>... functions) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Summarizer |
summarize(String numericColumn1Name,
String numericColumn2Name,
AggregateFunction<?,?>... functions) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Summarizer |
summarize(String columName,
AggregateFunction<?,?>... functions) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Summarizer |
summarize(List<String> columnNames,
AggregateFunction<?,?>... functions) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Summarizer |
summarize(Column<?> numberColumn,
AggregateFunction<?,?>... function) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Summarizer |
summarize(Column<?> column1,
Column<?> column2,
AggregateFunction<?,?>... function) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Summarizer |
summarize(Column<?> column1,
Column<?> column2,
Column<?> column3,
AggregateFunction<?,?>... function) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Summarizer |
summarize(Column<?> column1,
Column<?> column2,
Column<?> column3,
Column<?> column4,
AggregateFunction<?,?>... function) |
Returns an
Summarizer that can be used to summarize the column with the given name(s)
using the given functions. |
Table |
transpose() |
Transposes data in the table, switching rows for columns.
|
Table |
transpose(boolean includeColumnHeadingsAsFirstColumn,
boolean useFirstColumnForHeadings) |
Transposes data in the table, switching rows for columns.
|
Table |
where(Function<Table,Selection> selection) |
Returns a new Table made by applying the given function to this table
|
Table |
where(Selection selection) |
Returns a table containing the rows contained in the given Selection
|
DataFrameWriter |
write() |
Returns an object that an be used to write data from a Table into a file.
|
Table |
xTabColumnPercents(String column1Name,
String column2Name) |
Returns a table with n by m + 1 cells.
|
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) |
TODO: Rename the method to xTabProportions, deprecating this version 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) |
Returns a table with n by m + 1 cells.
|
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, containsColumn, dateColumn, dateColumn, dateColumns, dateTimeColumn, dateTimeColumn, dateTimeColumns, doubleColumn, doubleColumn, floatColumn, floatColumn, get, getString, getString, getUnformatted, instantColumn, instantColumn, instantColumns, intColumn, intColumn, isEmpty, longColumn, longColumn, nCol, nCol, numberColumn, numberColumn, numberColumns, numericColumns, numericColumns, numericColumns, print, print, printAll, shape, shortColumn, shortColumn, smile, stringColumn, stringColumn, stringColumns, structure, summary, textColumn, textColumn, timeColumn, timeColumn, timeColumns, toString, typeArray, types
public static final ReaderRegistry defaultReaderRegistry
public static final WriterRegistry defaultWriterRegistry
public static final String MELT_VARIABLE_COLUMN_NAME
public static final String MELT_VALUE_COLUMN_NAME
protected Table(String name, Column<?>... columns)
name
- The name of the tablecolumns
- One or more columns, all of which must have either the same length or size 0protected Table(String name, Collection<Column<?>> columns)
name
- The name of the tablecolumns
- One or more columns, all of which must have either the same length or size 0public static Table create()
public static Table create(String tableName)
public static Table create(Column<?>... columns)
columns
- one or more columns, all of the same @code{column.size()}public static Table create(Collection<Column<?>> columns)
columns
- one or more columns, all of the same @code{column.size()}public static Table create(Stream<Column<?>> columns)
columns
- one or more columns, all of the same @code{column.size()}public static Table create(String name, Column<?>... columns)
name
- the name for this tablecolumns
- one or more columns, all of the same @code{column.size()}public static Table create(String name, Collection<Column<?>> columns)
name
- the name for this tablecolumns
- one or more columns, all of the same @code{column.size()}public static Table create(String name, Stream<Column<?>> columns)
name
- the name for this tablecolumns
- 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 void internalAddWithoutValidation(Column<?> c)
Adds the given column to this table without performing duplicate-name or column size checks
public Table insertColumn(int index, Column<?> column)
index
- Zero-based index into the column listcolumn
- Column to be addedpublic Table reorderColumns(String... columnNames)
columnNames
- a column name or array of namespublic 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 Table replaceColumn(Column<?> newColumn)
newColumn
- 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)
categoricalColumns
in class Relation
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 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[] stratifiedSampleSplit(CategoricalColumn<?> column, double table1Proportion)
column
- the column to be used for the stratified samplingtable1Proportion
- 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)
if index is negative then sort that column in descending order otherwise sort ascending
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(Sort key)
key
- to sort on.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 table@Deprecated public void addRow(Row row)
append(Row)
instead.public Row row(int rowIndex)
public Table rows(int... rowNumbers)
public Table dropRows(int... rowNumbers)
public Table inRange(int rowCount)
public Table inRange(int rowStart, int rowEnd)
public Table dropRange(int rowCount)
public Table dropRange(int rowStart, int rowEnd)
public Table where(Selection selection)
public Table where(Function<Table,Selection> selection)
public Table dropWhere(Function<Table,Selection> selection)
public Table dropWhere(Selection selection)
public Table pivot(CategoricalColumn<?> column1, CategoricalColumn<?> column2, NumericColumn<?> column3, AggregateFunction<?,?> aggregateFunction)
public Table pivot(String column1Name, String column2Name, String column3Name, AggregateFunction<?,?> aggregateFunction)
public TableSliceGroup splitOn(String... columns)
This method is intended for advanced or unusual operations on the subtables. If you want to calculate summary statistics for each subtable, the summarize methods (e.g)
table.summarize(myColumn, mean, median).by(columns)
are preferred
public TableSliceGroup splitOn(CategoricalColumn<?>... columns)
This method is intended for advanced or unusual operations on the subtables. If you want to calculate summary statistics for each subtable, the summarize methods (e.g)
table.summarize(myColumn, mean, median).by(columns)
are preferred
public Table dropDuplicateRows()
public Table dropRowsWithMissingValues()
public Table selectColumns(Column<?>... columns)
columns
- The columns to copy into the new tableretainColumns(Column[])
public Table select(Column<?>... columns)
selectColumns(Column[])
insteadcolumns
- The columns to copy into the new tableretainColumns(Column[])
public Table selectColumns(String... columnNames)
columnNames
- The names of the columns to includeretainColumns(String[])
public Table select(String... columnNames)
selectColumns(String[])
insteadcolumnNames
- The names of the columns to includeretainColumns(String[])
public Table rejectColumns(int... columnIndexes)
columnIndexes
- The indexes of the columns to excluderemoveColumns(int[])
public Table rejectColumns(String... columnNames)
columnNames
- The names of the columns to excluderemoveColumns(int[])
public Table rejectColumns(Column<?>... columns)
columns
- The names of the columns to excluderemoveColumns(int[])
public Table selectColumns(int... columnIndexes)
columnIndexes
- The indexes of the columns to includeretainColumns(int[])
public Table removeColumns(Column<?>... columns)
removeColumns
in class Relation
public Table removeColumnsWithMissingValues()
public Table retainColumns(Column<?>... columns)
public Table retainColumns(int... columnIndexes)
public Table retainColumns(String... columnNames)
public Table append(Relation tableToAppend)
public Table append(Row row)
Note: The table is modified in-place TODO: Performance
public Table removeColumns(String... columns)
removeColumns
in class Relation
public Table removeColumns(int... columnIndexes)
removeColumns
in class Relation
public Row appendRow()
Intended usage:
for (int i = 0; ...) { Row row = table.appendRow(); row.setString("name", "Bob"); row.setFloat("IQ", 123.4f); ...etc. }
public Table concat(Table tableToConcatenate)
tableToConcatenate
- The table containing the columns to be addedpublic Summarizer summarize(String columName, AggregateFunction<?,?>... functions)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Summarizer summarize(List<String> columnNames, AggregateFunction<?,?>... functions)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Summarizer summarize(String numericColumn1Name, String numericColumn2Name, AggregateFunction<?,?>... functions)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Summarizer summarize(String col1Name, String col2Name, String col3Name, AggregateFunction<?,?>... functions)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Summarizer summarize(String col1Name, String col2Name, String col3Name, String col4Name, AggregateFunction<?,?>... functions)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Summarizer summarize(Column<?> numberColumn, AggregateFunction<?,?>... function)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Summarizer summarize(Column<?> column1, Column<?> column2, AggregateFunction<?,?>... function)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Summarizer summarize(Column<?> column1, Column<?> column2, Column<?> column3, AggregateFunction<?,?>... function)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Summarizer summarize(Column<?> column1, Column<?> column2, Column<?> column3, Column<?> column4, AggregateFunction<?,?>... function)
Summarizer
that can be used to summarize the column with the given name(s)
using the given functions. This object implements reduce/aggregation operations on a table.
Summarizer can return the results as a table using the Summarizer:apply() method. Summarizer can compute sub-totals using the Summarizer:by() method.
public Table xTabCounts(String column1Name, String column2Name)
public Table xTabRowPercents(String column1Name, String column2Name)
public Table xTabColumnPercents(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<?>... groupingColumns)
public Table countBy(String... categoricalColumnNames)
categoricalColumnNames
- The name(s) of one or more CategoricalColumns in this tableClassCastException
- if the categoricalColumnName parameter is the name of a column that
does not * implement categoricalpublic DataFrameJoiner joinOn(String... columnNames)
columnNames
columnNames
- Name of the columns to join on.public Table missingValueCounts()
public Iterator<Row[]> rollingIterator(int n)
n
- the number of rows to return for each iterationpublic Iterator<Row[]> steppingIterator(int n)
n
- the number of rows to return for each iterationpublic Stream<Row[]> steppingStream(int n)
n
- the number of rows to return for each iterationpublic Stream<Row[]> rollingStream(int n)
n
- the number of rows to return for each iterationpublic Table transpose()
Is transposed into the following
0 | 1 | 2 |
-------------------------------------
1 | 1.1 | 1.2 |
2 | 2.1 | 2.2 |
transpose(boolean,boolean)
public Table transpose(boolean includeColumnHeadingsAsFirstColumn, boolean useFirstColumnForHeadings)
Is transposed into the following
label | row1 | row2 | row3 |
-------------------------------------
value1 | 1 | 1.1 | 1.2 |
value2 | 2 | 2.1 | 2.2 |
includeColumnHeadingsAsFirstColumn
- Toggle whether to include the column headings as
first column in resultuseFirstColumnForHeadings
- Use the first column as the column headings in the result.
Useful if the data set already has a first column which contains a set of labelspublic Table melt(List<String> idVariables, List<NumericColumn<?>> measuredVariables, Boolean dropMissing)
Tidy concepts: {@see https://www.jstatsoft.org/article/view/v059i10}
Cast function details: {@see https://www.jstatsoft.org/article/view/v021i12}
In short, melt turns columns into rows, but in a particular way. Used with the cast method, it can help make data tidy. In a tidy dataset, every variable is a column and every observation a row.
This method returns a table that contains all the data in this table, but organized such that there is a set of identifier variables (columns) and a single measured variable (column). For example, given a table with columns:
patient_id, gender, age, weight, temperature,
it returns a table with the columns:
patient_id, variable, value
In the new format, the strings age, weight, and temperature have become cells in the measurement table, such that a single row in the source table might look like this in the result table:
1234, gender, male 1234, age, 42 1234, weight, 186 1234, temperature, 97.4
This kind of structure often makes for a good intermediate format for performing subsequent
transformations. It is especially useful when combined with the cast()
operation
idVariables
- A list of column names intended to be used as identifiers. In he example,
only patient_id would be an identifiermeasuredVariables
- A list of columns intended to be used as measured variables. All
columns must have the same typedropMissing
- drop any row where the value is missingpublic Table cast()
Cast takes a table in 'molten' format, such as is produced by the melt(List, List,
Boolean)
t} method, and returns a version in standard tidy format.
The molten table should have a StringColumn called "variable" and a column called "value" Every unique variable name will become a column in the output table.
All other columns in this table are considered identifier variable. Each combination of identifier variables specifies an observation, so there will be one row for each, with the other variables added.
Variable columns are returned in an arbitrary order. Use reorderColumns(String...)
if column order is important.
Tidy concepts: {@see https://www.jstatsoft.org/article/view/v059i10}
Cast function details: {@see https://www.jstatsoft.org/article/view/v021i12}
@Deprecated public void doWithRows(Consumer<Row> doable)
stream().forEach
doable
to every row in the table@Deprecated public boolean detect(Predicate<Row> predicate)
stream().anyMatch
@Deprecated public void stepWithRows(Consumer<Row[]> rowConsumer, int n)
@Deprecated public void doWithRows(tech.tablesaw.api.Table.Pairs pairs)
@Deprecated public void doWithRowPairs(Consumer<Table.RowPair> pairConsumer)
@Deprecated public void rollWithRows(Consumer<Row[]> rowConsumer, int n)
Copyright © 2021. All rights reserved.