Table extends Relation implements Iterable<Row> { public Table replaceColumn(final int colIndex, final Column<?> newColumn) { removeColumns(column(colIndex)); return insertColumn(colIndex, newColumn); } private  Table(); private  Table(String name); protected  Table(String name, Column<?>... columns); protected  Table(String name, Collection<Column<?>> columns); static Table create(); static Table create(String tableName); static Table create(Column<?>... columns); static Table create(Collection<Column<?>> columns); static Table create(Stream<Column<?>> columns); static Table create(String name, Column<?>... columns); static Table create(String name, Collection<Column<?>> columns); static Table create(String name, Stream<Column<?>> columns); static DataFrameReader read(); DataFrameWriter write(); @Override Table addColumns(final Column<?>... cols); void internalAddWithoutValidation(final Column<?> c); Table insertColumn(int index, Column<?> column); Table replaceColumn(final int colIndex, final Column<?> newColumn); Table replaceColumn(final String columnName, final Column<?> newColumn); Table replaceColumn(Column<?> newColumn); @Override Table setName(String name); @Override Column<?> column(int columnIndex); @Override int columnCount(); @Override int rowCount(); @Override List<Column<?>> columns(); Column<?>[] columnArray(); @Override List<CategoricalColumn<?>> categoricalColumns(String... columnNames); @Override int columnIndex(String columnName); int columnIndex(Column<?> column); @Override String name(); List<String> columnNames(); Table copy(); Table emptyCopy(); Table emptyCopy(int rowSize); Table[] sampleSplit(double table1Proportion); Table[] stratifiedSampleSplit(CategoricalColumn<?> column, double table1Proportion); Table sampleX(double proportion); Table sampleN(int nRows); @Override void clear(); Table first(int nRows); Table last(int nRows); Table sortOn(int... columnIndexes); Table sortOn(String... columnNames); Table sortAscendingOn(String... columnNames); Table sortDescendingOn(String... columnNames); Table sortOn(Sort key); Table sortOn(Comparator<Row> rowComparator); void addRow(int rowIndex, Table sourceTable); void addRow(Row row); Row row(int rowIndex); Table rows(int... rowNumbers); Table dropRows(int... rowNumbers); Table inRange(int rowCount); Table inRange(int rowStart, int rowEnd); Table dropRange(int rowCount); Table dropRange(int rowStart, int rowEnd); Table where(Selection selection); Table where(Function<Table, Selection> selection); Table dropWhere(Function<Table, Selection> selection); Table dropWhere(Selection selection); Table pivot(
      CategoricalColumn<?> column1,
      CategoricalColumn<?> column2,
      NumericColumn<?> column3,
      AggregateFunction<?, ?> aggregateFunction); Table pivot(
      String column1Name,
      String column2Name,
      String column3Name,
      AggregateFunction<?, ?> aggregateFunction); TableSliceGroup splitOn(String... columns); TableSliceGroup splitOn(CategoricalColumn<?>... columns); @Override Table structure(); Table dropDuplicateRows(); Table dropRowsWithMissingValues(); Table select(Column<?>... columns); Table select(String... columnNames); @Override Table removeColumns(Column<?>... columns); Table removeColumnsWithMissingValues(); Table retainColumns(Column<?>... columns); Table retainColumns(String... columnNames); @SuppressWarnings({"rawtypes", "unchecked"}) Table append(Table tableToAppend); Row appendRow(); Table concat(Table tableToConcatenate); Summarizer summarize(String columName, AggregateFunction<?, ?>... functions); Summarizer summarize(List<String> columnNames, AggregateFunction<?, ?>... functions); Summarizer summarize(
      String numericColumn1Name, String numericColumn2Name, AggregateFunction<?, ?>... functions); Summarizer summarize(
      String col1Name, String col2Name, String col3Name, AggregateFunction<?, ?>... functions); Summarizer summarize(
      String col1Name,
      String col2Name,
      String col3Name,
      String col4Name,
      AggregateFunction<?, ?>... functions); Summarizer summarize(Column<?> numberColumn, AggregateFunction<?, ?>... function); 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); Table xTabCounts(String column1Name, String column2Name); Table xTabRowPercents(String column1Name, String column2Name); Table xTabColumnPercents(String column1Name, String column2Name); Table xTabTablePercents(String column1Name, String column2Name); Table xTabPercents(String column1Name); Table xTabCounts(String column1Name); Table countBy(CategoricalColumn<?> groupingColumn); Table countBy(String categoricalColumnName); DataFrameJoiner joinOn(String... columnNames); Table missingValueCounts(); @Override Iterator<Row> iterator(); Iterator<Row[]> rollingIterator(int n); Iterator<Row[]> steppingIterator(int n); Stream<Row> stream(); Stream<Row[]> steppingStream(int n); Stream<Row[]> rollingStream(int n); Table transpose(); Table transpose(
      boolean includeColumnHeadingsAsFirstColumn, boolean useFirstColumnForHeadings); @Deprecated void doWithRows(Consumer<Row> doable); @Deprecated boolean detect(Predicate<Row> predicate); @Deprecated void stepWithRows(Consumer<Row[]> rowConsumer, int n); @Deprecated void doWithRows(Pairs pairs); @Deprecated void doWithRowPairs(Consumer<RowPair> pairConsumer); @Deprecated void rollWithRows(Consumer<Row[]> rowConsumer, int n); static final ReaderRegistry defaultReaderRegistry; static final WriterRegistry defaultWriterRegistry; }
@Test void testReplaceColumn() { DoubleColumn first = DoubleColumn.create("c1", new double[] {1, 2, 3, 4, 5}); DoubleColumn second = DoubleColumn.create("c2", new double[] {6, 7, 8, 9, 10}); DoubleColumn replacement = DoubleColumn.create("c2", new double[] {10, 20, 30, 40, 50}); Table t = Table.create("populated", first, second); int colIndex = t.columnIndex(second); assertSame(t.column("c2"), second); t.replaceColumn("c2", replacement); assertSame(t.column("c1"), first); assertSame(t.column("c2"), replacement); assertEquals(t.columnIndex(replacement), colIndex); }