Repository: jtablesaw/tablesaw
Pull request #634 (2019-08-25 04:03:24)

Column creation from streams
Thanks for contributing.

- [X] Tick to sign-off your agreement to the [Developer Certificate of Origin (DCO) 1.1](https://developercertificate.org)

## Description

I use Java 8 streams a lot. This makes column creation a bit easier

benmccann: The reason I didn't add support for floats and shorts is that the Java Stream API only supports map to object, int, long, and double. I suppose for float I could take a `DoubleStream` and for short I could take an `IntStream`, but I wasn't sure if it was worth adding that or not
lwhite1: Oh right. That was kinda half-assed of them. I think it would be better to
either use larger types, or object types (e.g. Stream<Float>) than to leave
holes in our API.

On Sun, Aug 25, 2019 at 12:35 PM Ben McCann <notifications@github.com>
wrote:

> The reason I didn't add support for floats and shorts is that the Java
> Stream API only supports map to object, int, long, and double. I suppose
> for float I could take a DoubleStream and for short I could take an
> IntStream, but I wasn't sure if it was worth adding that or not
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/jtablesaw/tablesaw/pull/634?email_source=notifications&email_token=AA2FPARZMGOELNGKDHGSYI3QGKYF3A5CNFSM4IPH5CP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5CW5XA#issuecomment-524644060>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AA2FPAQYZMYQVDTYJCAX62LQGKYF3ANCNFSM4IPH5CPQ>
> .
>

benmccann: Ok. I've updated it to use `Stream<Float>`, etc.

Patch:
diff --git a/core/src/main/java/tech/tablesaw/api/BooleanColumn.java b/core/src/main/java/tech/tablesaw/api/BooleanColumn.java
index 6703940a..55a65fdd 100644
--- a/core/src/main/java/tech/tablesaw/api/BooleanColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/BooleanColumn.java
@@ -39,6 +39,7 @@ import java.util.function.BiPredicate;
 import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumn;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
@@ -120,7 +121,6 @@ public class BooleanColumn extends AbstractColumn<Boolean>
   }
 
   public static BooleanColumn create(String name, boolean[] values) {
-
     BooleanColumn column = create(name, values.length);
     int r = 0;
     for (boolean b : values) {
@@ -138,14 +138,20 @@ public class BooleanColumn extends AbstractColumn<Boolean>
     return column;
   }
 
-  public static BooleanColumn create(String name, Boolean[] objects) {
+  public static BooleanColumn create(String name, Boolean[] arr) {
     BooleanColumn column = create(name);
-    for (Boolean b : objects) {
-      column.append(b);
+    for (Boolean val : arr) {
+      column.append(val);
     }
     return column;
   }
 
+  public static BooleanColumn create(String name, Stream<Boolean> stream) {
+    BooleanColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   @Override
   public BooleanColumn setName(String name) {
     return (BooleanColumn) super.setName(name);
diff --git a/core/src/main/java/tech/tablesaw/api/DateColumn.java b/core/src/main/java/tech/tablesaw/api/DateColumn.java
index d9b811b7..cc59b924 100644
--- a/core/src/main/java/tech/tablesaw/api/DateColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/DateColumn.java
@@ -35,6 +35,7 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumn;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
@@ -95,6 +96,12 @@ public class DateColumn extends AbstractColumn<LocalDate>
     return column;
   }
 
+  public static DateColumn create(String name, Stream<LocalDate> stream) {
+    DateColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   private DateColumn(String name, IntArrayList data) {
     super(DateColumnType.instance(), name);
     this.data = data;
diff --git a/core/src/main/java/tech/tablesaw/api/DateTimeColumn.java b/core/src/main/java/tech/tablesaw/api/DateTimeColumn.java
index 2a0f5fcd..e5c4d901 100644
--- a/core/src/main/java/tech/tablesaw/api/DateTimeColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/DateTimeColumn.java
@@ -41,6 +41,7 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumn;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
@@ -98,6 +99,12 @@ public class DateTimeColumn extends AbstractColumn<LocalDateTime>
     return column;
   }
 
+  public static DateTimeColumn create(String name, Stream<LocalDateTime> stream) {
+    DateTimeColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   @Override
   public DateTimeColumn plus(long amountToAdd, ChronoUnit unit) {
     DateTimeColumn newColumn = emptyCopy();
diff --git a/core/src/main/java/tech/tablesaw/api/DoubleColumn.java b/core/src/main/java/tech/tablesaw/api/DoubleColumn.java
index c25e69bf..f5522184 100644
--- a/core/src/main/java/tech/tablesaw/api/DoubleColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/DoubleColumn.java
@@ -18,6 +18,7 @@ import java.util.function.DoublePredicate;
 import java.util.function.DoubleSupplier;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.stream.DoubleStream;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
 import tech.tablesaw.columns.numbers.DoubleColumnType;
@@ -36,7 +37,7 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
 
   private final DoubleArrayList data;
 
-  protected DoubleColumn(final String name, final DoubleArrayList data) {
+  protected DoubleColumn(String name, DoubleArrayList data) {
     super(DoubleColumnType.instance(), name);
     setPrintFormatter(NumberColumnFormatter.floatingPointDefault());
     this.data = data;
@@ -47,7 +48,7 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
   }
 
   @Override
-  public String getString(final int row) {
+  public String getString(int row) {
     final double value = getDouble(row);
     if (DoubleColumnType.isMissingValue(value)) {
       return "";
@@ -70,21 +71,21 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
     return this;
   }
 
-  protected DoubleColumn(final String name) {
+  protected DoubleColumn(String name) {
     super(DoubleColumnType.instance(), name);
     setPrintFormatter(NumberColumnFormatter.floatingPointDefault());
     this.data = new DoubleArrayList(DEFAULT_ARRAY_SIZE);
   }
 
-  public static DoubleColumn create(final String name, final double[] arr) {
+  public static DoubleColumn create(String name, double[] arr) {
     return new DoubleColumn(name, new DoubleArrayList(arr));
   }
 
-  public static DoubleColumn create(final String name) {
+  public static DoubleColumn create(String name) {
     return new DoubleColumn(name);
   }
 
-  public static DoubleColumn create(final String name, final float[] arr) {
+  public static DoubleColumn create(String name, float[] arr) {
     final double[] doubles = new double[arr.length];
     for (int i = 0; i < arr.length; i++) {
       doubles[i] = arr[i];
@@ -92,7 +93,7 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
     return new DoubleColumn(name, new DoubleArrayList(doubles));
   }
 
-  public static DoubleColumn create(final String name, final int[] arr) {
+  public static DoubleColumn create(String name, int[] arr) {
     final double[] doubles = new double[arr.length];
     for (int i = 0; i < arr.length; i++) {
       doubles[i] = arr[i];
@@ -100,7 +101,7 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
     return new DoubleColumn(name, new DoubleArrayList(doubles));
   }
 
-  public static DoubleColumn create(final String name, final long[] arr) {
+  public static DoubleColumn create(String name, long[] arr) {
     final double[] doubles = new double[arr.length];
     for (int i = 0; i < arr.length; i++) {
       doubles[i] = arr[i];
@@ -108,7 +109,7 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
     return new DoubleColumn(name, new DoubleArrayList(doubles));
   }
 
-  public static DoubleColumn create(final String name, final List<Number> numberList) {
+  public static DoubleColumn create(String name, List<Number> numberList) {
     DoubleColumn newColumn = new DoubleColumn(name, new DoubleArrayList(0));
     for (Number number : numberList) {
       newColumn.append(number);
@@ -116,7 +117,7 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
     return newColumn;
   }
 
-  public static DoubleColumn create(final String name, final Number[] numbers) {
+  public static DoubleColumn create(String name, Number[] numbers) {
     DoubleColumn newColumn = new DoubleColumn(name, new DoubleArrayList(0));
     for (Number number : numbers) {
       newColumn.append(number);
@@ -124,7 +125,7 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
     return newColumn;
   }
 
-  public static DoubleColumn create(final String name, final int initialSize) {
+  public static DoubleColumn create(String name, int initialSize) {
     DoubleColumn column = new DoubleColumn(name);
     for (int i = 0; i < initialSize; i++) {
       column.appendMissing();
@@ -132,13 +133,19 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
     return column;
   }
 
+  public static DoubleColumn create(String name, DoubleStream stream) {
+    DoubleArrayList list = new DoubleArrayList();
+    stream.forEach(val -> list.add(val));
+    return new DoubleColumn(name, list);
+  }
+
   @Override
-  public DoubleColumn createCol(final String name, final int initialSize) {
+  public DoubleColumn createCol(String name, int initialSize) {
     return create(name, initialSize);
   }
 
   @Override
-  public DoubleColumn createCol(final String name) {
+  public DoubleColumn createCol(String name) {
     return create(name);
   }
 
@@ -148,7 +155,7 @@ public class DoubleColumn extends NumberColumn<Double> implements NumberFillers<
   }
 
   @Override
-  public DoubleColumn subset(final int[] rows) {
+  public DoubleColumn subset(int[] rows) {
     final DoubleColumn c = this.emptyCopy();
     for (final int row : rows) {
       c.append(getDouble(row));
diff --git a/core/src/main/java/tech/tablesaw/api/FloatColumn.java b/core/src/main/java/tech/tablesaw/api/FloatColumn.java
index 900e3da1..0ad5b55f 100644
--- a/core/src/main/java/tech/tablesaw/api/FloatColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/FloatColumn.java
@@ -13,6 +13,7 @@ import java.util.Iterator;
 import java.util.function.DoublePredicate;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
 import tech.tablesaw.columns.numbers.FloatColumnType;
@@ -28,14 +29,14 @@ public class FloatColumn extends NumberColumn<Float> {
 
   private final FloatArrayList data;
 
-  private FloatColumn(final String name, FloatArrayList data) {
+  private FloatColumn(String name, FloatArrayList data) {
     super(FloatColumnType.instance(), name);
     setPrintFormatter(NumberColumnFormatter.floatingPointDefault());
     this.data = data;
   }
 
   @Override
-  public String getString(final int row) {
+  public String getString(int row) {
     final float value = getFloat(row);
     if (FloatColumnType.isMissingValue(value)) {
       return "";
@@ -43,15 +44,15 @@ public class FloatColumn extends NumberColumn<Float> {
     return String.valueOf(getPrintFormatter().format(value));
   }
 
-  public static FloatColumn create(final String name) {
+  public static FloatColumn create(String name) {
     return new FloatColumn(name, new FloatArrayList());
   }
 
-  public static FloatColumn create(final String name, final float[] arr) {
+  public static FloatColumn create(String name, float[] arr) {
     return new FloatColumn(name, new FloatArrayList(arr));
   }
 
-  public static FloatColumn create(final String name, final int initialSize) {
+  public static FloatColumn create(String name, int initialSize) {
     FloatColumn column = new FloatColumn(name, new FloatArrayList(initialSize));
     for (int i = 0; i < initialSize; i++) {
       column.appendMissing();
@@ -59,13 +60,27 @@ public class FloatColumn extends NumberColumn<Float> {
     return column;
   }
 
+  public static FloatColumn create(String name, Float[] arr) {
+    FloatColumn column = create(name);
+    for (Float val : arr) {
+      column.append(val);
+    }
+    return column;
+  }
+
+  public static FloatColumn create(String name, Stream<Float> stream) {
+    FloatColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   @Override
-  public FloatColumn createCol(final String name, final int initialSize) {
+  public FloatColumn createCol(String name, int initialSize) {
     return create(name, initialSize);
   }
 
   @Override
-  public FloatColumn createCol(final String name) {
+  public FloatColumn createCol(String name) {
     return create(name);
   }
 
@@ -79,7 +94,7 @@ public class FloatColumn extends NumberColumn<Float> {
   }
 
   @Override
-  public FloatColumn subset(final int[] rows) {
+  public FloatColumn subset(int[] rows) {
     final FloatColumn c = this.emptyCopy();
     for (final int row : rows) {
       c.append(getFloat(row));
diff --git a/core/src/main/java/tech/tablesaw/api/InstantColumn.java b/core/src/main/java/tech/tablesaw/api/InstantColumn.java
index 0c7d391b..0c29a6c5 100644
--- a/core/src/main/java/tech/tablesaw/api/InstantColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/InstantColumn.java
@@ -43,6 +43,7 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumn;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
@@ -108,6 +109,12 @@ public class InstantColumn extends AbstractColumn<Instant>
     return column;
   }
 
+  public static InstantColumn create(String name, Stream<Instant> stream) {
+    InstantColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   public static boolean valueIsMissing(long value) {
     return InstantColumnType.isMissingValue(value);
   }
diff --git a/core/src/main/java/tech/tablesaw/api/IntColumn.java b/core/src/main/java/tech/tablesaw/api/IntColumn.java
index 7e0b6650..46b66535 100644
--- a/core/src/main/java/tech/tablesaw/api/IntColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/IntColumn.java
@@ -13,6 +13,7 @@ import java.util.Iterator;
 import java.util.function.DoublePredicate;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.stream.IntStream;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
 import tech.tablesaw.columns.numbers.DoubleColumnType;
@@ -49,7 +50,7 @@ public class IntColumn extends NumberColumn<Integer> implements CategoricalColum
     return newColumn;
   }
 
-  public static IntColumn create(final String name, final int initialSize) {
+  public static IntColumn create(String name, int initialSize) {
     IntColumn column = new IntColumn(name, new IntArrayList(initialSize));
     for (int i = 0; i < initialSize; i++) {
       column.appendMissing();
@@ -57,13 +58,19 @@ public class IntColumn extends NumberColumn<Integer> implements CategoricalColum
     return column;
   }
 
+  public static IntColumn create(String name, IntStream stream) {
+    IntArrayList list = new IntArrayList();
+    stream.forEach(val -> list.add(val));
+    return new IntColumn(name, list);
+  }
+
   @Override
-  public IntColumn createCol(final String name, final int initialSize) {
+  public IntColumn createCol(String name, int initialSize) {
     return create(name, initialSize);
   }
 
   @Override
-  public IntColumn createCol(final String name) {
+  public IntColumn createCol(String name) {
     return create(name);
   }
 
diff --git a/core/src/main/java/tech/tablesaw/api/LongColumn.java b/core/src/main/java/tech/tablesaw/api/LongColumn.java
index f2e1e26e..32dc9dec 100644
--- a/core/src/main/java/tech/tablesaw/api/LongColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/LongColumn.java
@@ -15,6 +15,7 @@ import java.util.Iterator;
 import java.util.function.DoublePredicate;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.stream.LongStream;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
 import tech.tablesaw.columns.numbers.DoubleColumnType;
@@ -29,7 +30,7 @@ public class LongColumn extends NumberColumn<Long> implements CategoricalColumn<
 
   private final LongArrayList data;
 
-  private LongColumn(final String name, LongArrayList data) {
+  private LongColumn(String name, LongArrayList data) {
     super(LongColumnType.instance(), name);
     setPrintFormatter(NumberColumnFormatter.ints());
     this.data = data;
@@ -39,11 +40,11 @@ public class LongColumn extends NumberColumn<Long> implements CategoricalColumn<
     return new LongColumn(name, new LongArrayList());
   }
 
-  public static LongColumn create(final String name, final long[] arr) {
+  public static LongColumn create(String name, long[] arr) {
     return new LongColumn(name, new LongArrayList(arr));
   }
 
-  public static LongColumn create(final String name, final int initialSize) {
+  public static LongColumn create(String name, int initialSize) {
     LongColumn column = new LongColumn(name, new LongArrayList(initialSize));
     for (int i = 0; i < initialSize; i++) {
       column.appendMissing();
@@ -51,13 +52,19 @@ public class LongColumn extends NumberColumn<Long> implements CategoricalColumn<
     return column;
   }
 
+  public static LongColumn create(String name, LongStream stream) {
+    LongArrayList list = new LongArrayList();
+    stream.forEach(val -> list.add(val));
+    return new LongColumn(name, list);
+  }
+
   @Override
-  public LongColumn createCol(final String name, final int initialSize) {
+  public LongColumn createCol(String name, int initialSize) {
     return create(name, initialSize);
   }
 
   @Override
-  public LongColumn createCol(final String name) {
+  public LongColumn createCol(String name) {
     return create(name);
   }
 
diff --git a/core/src/main/java/tech/tablesaw/api/ShortColumn.java b/core/src/main/java/tech/tablesaw/api/ShortColumn.java
index 60805874..613900f9 100644
--- a/core/src/main/java/tech/tablesaw/api/ShortColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/ShortColumn.java
@@ -1,6 +1,7 @@
 package tech.tablesaw.api;
 
 import com.google.common.base.Preconditions;
+import com.google.common.primitives.Shorts;
 import it.unimi.dsi.fastutil.shorts.ShortArrayList;
 import it.unimi.dsi.fastutil.shorts.ShortArrays;
 import it.unimi.dsi.fastutil.shorts.ShortComparator;
@@ -8,11 +9,13 @@ import it.unimi.dsi.fastutil.shorts.ShortListIterator;
 import it.unimi.dsi.fastutil.shorts.ShortOpenHashSet;
 import it.unimi.dsi.fastutil.shorts.ShortSet;
 import java.nio.ByteBuffer;
+import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.function.DoublePredicate;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
 import tech.tablesaw.columns.numbers.DoubleColumnType;
@@ -49,6 +52,16 @@ public class ShortColumn extends NumberColumn<Short> implements CategoricalColum
     return column;
   }
 
+  public static ShortColumn create(final String name, final Short[] arr) {
+    return new ShortColumn(name, new ShortArrayList(Shorts.toArray(Arrays.asList(arr))));
+  }
+
+  public static ShortColumn create(String name, Stream<Short> stream) {
+    ShortColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   @Override
   public ShortColumn createCol(final String name, final int initialSize) {
     return create(name, initialSize);
diff --git a/core/src/main/java/tech/tablesaw/api/StringColumn.java b/core/src/main/java/tech/tablesaw/api/StringColumn.java
index a36b672c..b8928f92 100644
--- a/core/src/main/java/tech/tablesaw/api/StringColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/StringColumn.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Set;
 import java.util.function.Function;
 import java.util.function.Predicate;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
 import tech.tablesaw.columns.strings.AbstractStringColumn;
@@ -85,6 +86,12 @@ public class StringColumn extends AbstractStringColumn {
     return column;
   }
 
+  public static StringColumn create(String name, Stream<String> stream) {
+    StringColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   private StringColumn(String name, List<String> strings) {
     super(StringColumnType.instance(), name);
     for (String string : strings) {
diff --git a/core/src/main/java/tech/tablesaw/api/TextColumn.java b/core/src/main/java/tech/tablesaw/api/TextColumn.java
index 359033fb..0c5aa668 100644
--- a/core/src/main/java/tech/tablesaw/api/TextColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/TextColumn.java
@@ -24,6 +24,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
 import tech.tablesaw.columns.strings.AbstractStringColumn;
@@ -105,6 +106,12 @@ public class TextColumn extends AbstractStringColumn {
     return new TextColumn(name, strings);
   }
 
+  public static TextColumn create(String name, Stream<String> stream) {
+    TextColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   @Override
   public boolean isMissing(int rowNumber) {
     return get(rowNumber).equals(TextColumnType.missingValueIndicator());
diff --git a/core/src/main/java/tech/tablesaw/api/TimeColumn.java b/core/src/main/java/tech/tablesaw/api/TimeColumn.java
index afb60d46..0c3c8f76 100644
--- a/core/src/main/java/tech/tablesaw/api/TimeColumn.java
+++ b/core/src/main/java/tech/tablesaw/api/TimeColumn.java
@@ -36,6 +36,7 @@ import java.util.function.Consumer;
 import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
+import java.util.stream.Stream;
 import tech.tablesaw.columns.AbstractColumn;
 import tech.tablesaw.columns.AbstractColumnParser;
 import tech.tablesaw.columns.Column;
@@ -110,6 +111,12 @@ public class TimeColumn extends AbstractColumn<LocalTime>
     return column;
   }
 
+  public static TimeColumn create(String name, Stream<LocalTime> stream) {
+    TimeColumn column = create(name);
+    stream.forEach(val -> column.append(val));
+    return column;
+  }
+
   @Override
   public TimeColumn appendMissing() {
     appendInternal(TimeColumnType.missingValueIndicator());


Test patch:
diff --git a/core/src/test/java/tech/tablesaw/api/FloatColumnTest.java b/core/src/test/java/tech/tablesaw/api/FloatColumnTest.java
index 2e49443c..e2926a23 100644
--- a/core/src/test/java/tech/tablesaw/api/FloatColumnTest.java
+++ b/core/src/test/java/tech/tablesaw/api/FloatColumnTest.java
@@ -15,24 +15,34 @@
 package tech.tablesaw.api;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
 
 public class FloatColumnTest {
 
   @Test
-  public void testAppendFloat() {
-    final FloatColumn floatColumn = FloatColumn.create("floats");
-    final Float floatValue = 2.5f;
+  public void appendFloat() {
+    FloatColumn floatColumn = FloatColumn.create("floats");
+    Float floatValue = 2.5f;
     floatColumn.append(floatValue);
     assertEquals(floatValue, floatColumn.get(0));
   }
 
   @Test
-  public void testAppendFloatObject() {
-    final FloatColumn floatColumn = FloatColumn.create("floats");
-    final Float floatObject = 2.5f;
+  public void appendFloatObject() {
+    FloatColumn floatColumn = FloatColumn.create("floats");
+    Float floatObject = 2.5f;
     floatColumn.append(floatObject);
     assertEquals(floatObject, floatColumn.get(0));
   }
+
+  @Test
+  public void createFromObjectArray() {
+    Float[] floats = new Float[] {2.5f, null, 4.0f};
+    FloatColumn floatColumn = FloatColumn.create("floats", floats);
+    assertEquals(2.5f, floatColumn.get(0));
+    assertTrue(floatColumn.isMissing(1));
+    assertEquals(4.0f, floatColumn.get(2));
+  }
 }