示例#1
0
        public void TestConcatenate()
        {
            var df1 = new DataFrame();

            df1.AddColumn("x", new int[] { 1, 2 });
            df1.AddColumn("y", new string[] { "a", "b" });

            var df2 = new DataFrame();

            df2.AddColumn("x", new int[] { 3, 4 });
            df2.AddColumn("z", new string[] { "c", "d" });

            var result = DataFrame.Concatenate(df1, df2);

            CollectionAssert.AreEqual(new string[] { "x", "y", "z" }, result.ColumnNames);

            Assert.AreEqual(4, result[0].Count);
            Assert.AreEqual(4, result[1].Count);
            Assert.AreEqual(4, result[2].Count);

            CollectionAssert.AreEqual(new object[] { 1, 2, 3, 4 }, result[0].ToObjectArray());
            CollectionAssert.AreEqual(new object[] { "a", "b", null, null }, result[1].ToObjectArray());
            CollectionAssert.AreEqual(new object[] { null, null, "c", "d" }, result[2].ToObjectArray());
        }