@Test public void testFoldDoubleByColumn() { DataFrame df = DataFrameBuilder .builder("a", "b") .foldDoubleByColumn(-9999.9, 0, 1.1, 2, 3, 4, 5); new DataFrameAsserts(df, "a", "b").expectHeight(3) .expectDoubleColumns(0, 1) .expectRow(0, 0., 3.) .expectRow(1, 1.1, 4.) .expectRow(2, 2., 5.); }
public DataFrame foldDoubleByColumn(double padWith, double... data) { FoldByColumnGeometry g = byColumnGeometry(data.length); double[][] columnarData = new double[g.width][g.height]; for (int i = 0; i < g.fullColumns; i++) { System.arraycopy(data, i * g.height, columnarData[i], 0, g.height); } if (g.isLastColumnPartial()) { System.arraycopy(data, g.cellsInFullColumns(), columnarData[g.fullColumns], 0, g.partialColumnHeight); if (padWith != 0.) { Arrays.fill(columnarData[g.fullColumns], g.partialColumnHeight, g.height, padWith); } } Series[] series = new Series[g.width]; for (int i = 0; i < g.width; i++) { series[i] = new DoubleArraySeries(columnarData[i]); } return new ColumnDataFrame(columnsIndex, series); }
DataFrameBuilder { public DataFrame foldDoubleByColumn(double padWith, double... data) { FoldByColumnGeometry g = byColumnGeometry(data.length); double[][] columnarData = new double[g.width][g.height]; for (int i = 0; i < g.fullColumns; i++) { System.arraycopy(data, i * g.height, columnarData[i], 0, g.height); } if (g.isLastColumnPartial()) { System.arraycopy(data, g.cellsInFullColumns(), columnarData[g.fullColumns], 0, g.partialColumnHeight); if (padWith != 0.) { Arrays.fill(columnarData[g.fullColumns], g.partialColumnHeight, g.height, padWith); } } Series[] series = new Series[g.width]; for (int i = 0; i < g.width; i++) { series[i] = new DoubleArraySeries(columnarData[i]); } return new ColumnDataFrame(columnsIndex, series); } }
DataFrameBuilder { public DataFrame foldDoubleByColumn(double padWith, double... data) { FoldByColumnGeometry g = byColumnGeometry(data.length); double[][] columnarData = new double[g.width][g.height]; for (int i = 0; i < g.fullColumns; i++) { System.arraycopy(data, i * g.height, columnarData[i], 0, g.height); } if (g.isLastColumnPartial()) { System.arraycopy(data, g.cellsInFullColumns(), columnarData[g.fullColumns], 0, g.partialColumnHeight); if (padWith != 0.) { Arrays.fill(columnarData[g.fullColumns], g.partialColumnHeight, g.height, padWith); } } Series[] series = new Series[g.width]; for (int i = 0; i < g.width; i++) { series[i] = new DoubleArraySeries(columnarData[i]); } return new ColumnDataFrame(columnsIndex, series); } protected  DataFrameBuilder(Index columnsIndex); }
DataFrameBuilder { public DataFrame foldDoubleByColumn(double padWith, double... data) { FoldByColumnGeometry g = byColumnGeometry(data.length); double[][] columnarData = new double[g.width][g.height]; for (int i = 0; i < g.fullColumns; i++) { System.arraycopy(data, i * g.height, columnarData[i], 0, g.height); } if (g.isLastColumnPartial()) { System.arraycopy(data, g.cellsInFullColumns(), columnarData[g.fullColumns], 0, g.partialColumnHeight); if (padWith != 0.) { Arrays.fill(columnarData[g.fullColumns], g.partialColumnHeight, g.height, padWith); } } Series[] series = new Series[g.width]; for (int i = 0; i < g.width; i++) { series[i] = new DoubleArraySeries(columnarData[i]); } return new ColumnDataFrame(columnsIndex, series); } protected  DataFrameBuilder(Index columnsIndex); static DataFrameBuilder builder(String... columnLabels); static DataFrameBuilder builder(Index columnsIndex); DataFrame empty(); DataFrame columns(Series<?>... columns); DataFrame rows(Object[]... rows); DataFrameByRowBuilder byRow(); DataFrameByRowBuilder addRow(Object... row); DataFrame foldByRow(Object... data); DataFrame foldByColumn(Object... data); DataFrame foldStreamByRow(Stream<T> stream); DataFrame foldStreamByColumn(Stream<T> stream); DataFrame foldIterableByRow(Iterable<T> iterable); DataFrame foldIterableByColumn(Iterable<T> iterable); DataFrame objectsToRows(Iterable<T> objects, Function<T, Object[]> rowMapper); DataFrame foldIntByColumn(int padWith, int... data); DataFrame foldIntStreamByRow(IntStream stream); DataFrame foldIntStreamByRow(int padWith, IntStream stream); DataFrame foldIntStreamByColumn(IntStream stream); DataFrame foldIntStreamByColumn(int padWith, IntStream stream); DataFrame foldLongByColumn(long padWith, long... data); DataFrame foldLongStreamByRow(LongStream stream); DataFrame foldLongStreamByRow(long padWith, LongStream stream); DataFrame foldLongStreamByColumn(LongStream stream); DataFrame foldLongStreamByColumn(long padWith, LongStream stream); DataFrame foldDoubleByColumn(double padWith, double... data); DataFrame foldDoubleStreamByRow(DoubleStream stream); DataFrame foldDoubleStreamByRow(double padWith, DoubleStream stream); DataFrame foldDoubleStreamByColumn(DoubleStream stream); DataFrame foldDoubleStreamByColumn(double padWith, DoubleStream stream); }
DataFrameBuilder { public DataFrame foldDoubleByColumn(double padWith, double... data) { FoldByColumnGeometry g = byColumnGeometry(data.length); double[][] columnarData = new double[g.width][g.height]; for (int i = 0; i < g.fullColumns; i++) { System.arraycopy(data, i * g.height, columnarData[i], 0, g.height); } if (g.isLastColumnPartial()) { System.arraycopy(data, g.cellsInFullColumns(), columnarData[g.fullColumns], 0, g.partialColumnHeight); if (padWith != 0.) { Arrays.fill(columnarData[g.fullColumns], g.partialColumnHeight, g.height, padWith); } } Series[] series = new Series[g.width]; for (int i = 0; i < g.width; i++) { series[i] = new DoubleArraySeries(columnarData[i]); } return new ColumnDataFrame(columnsIndex, series); } protected  DataFrameBuilder(Index columnsIndex); static DataFrameBuilder builder(String... columnLabels); static DataFrameBuilder builder(Index columnsIndex); DataFrame empty(); DataFrame columns(Series<?>... columns); DataFrame rows(Object[]... rows); DataFrameByRowBuilder byRow(); DataFrameByRowBuilder addRow(Object... row); DataFrame foldByRow(Object... data); DataFrame foldByColumn(Object... data); DataFrame foldStreamByRow(Stream<T> stream); DataFrame foldStreamByColumn(Stream<T> stream); DataFrame foldIterableByRow(Iterable<T> iterable); DataFrame foldIterableByColumn(Iterable<T> iterable); DataFrame objectsToRows(Iterable<T> objects, Function<T, Object[]> rowMapper); DataFrame foldIntByColumn(int padWith, int... data); DataFrame foldIntStreamByRow(IntStream stream); DataFrame foldIntStreamByRow(int padWith, IntStream stream); DataFrame foldIntStreamByColumn(IntStream stream); DataFrame foldIntStreamByColumn(int padWith, IntStream stream); DataFrame foldLongByColumn(long padWith, long... data); DataFrame foldLongStreamByRow(LongStream stream); DataFrame foldLongStreamByRow(long padWith, LongStream stream); DataFrame foldLongStreamByColumn(LongStream stream); DataFrame foldLongStreamByColumn(long padWith, LongStream stream); DataFrame foldDoubleByColumn(double padWith, double... data); DataFrame foldDoubleStreamByRow(DoubleStream stream); DataFrame foldDoubleStreamByRow(double padWith, DoubleStream stream); DataFrame foldDoubleStreamByColumn(DoubleStream stream); DataFrame foldDoubleStreamByColumn(double padWith, DoubleStream stream);  }