Exemple #1
0
    def test_assemble_concatenated_meta(self):
        # Happy path
        meta1 = pd.DataFrame([["a", "b"], ["c", "d"]],
                             index=["c1", "c2"],
                             columns=["hd1", "hd2"])
        meta2 = pd.DataFrame([["e", "f", "g"], ["h", "i", "j"]],
                             index=["c2", "c3"],
                             columns=["hd1", "hd2", "hd3"])
        e_concated = pd.DataFrame([["a", "b", np.nan], ["e", "f", "g"],
                                   ["c", "d", np.nan], ["h", "i", "j"]],
                                  index=["c1", "c2", "c2", "c3"],
                                  columns=["hd1", "hd2", "hd3"])

        logger.debug("meta1:\n{}".format(meta1))
        logger.debug("meta2:\n{}".format(meta2))
        logger.debug("e_concated:\n{}".format(e_concated))

        concated = cg.assemble_concatenated_meta([meta2, meta1], False)
        logger.debug("happy path - concated:\n{}".format(concated))
        pd.util.testing.assert_frame_equal(e_concated, concated)

        #remove all metadata
        r = cg.assemble_concatenated_meta([meta2, meta1], True)
        logger.debug("remove all metadata - r:\n{}".format(r))
        self.assertEqual((4, 0), r.shape)
        self.assertTrue((e_concated.index == r.index).all())
Exemple #2
0
    def test_assemble_concatenated_meta(self):
        # Happy path
        meta1 = pd.DataFrame([["a", "b"], ["c", "d"]],
                             index=["c1", "c2"],
                             columns=["hd1", "hd2"])
        meta2 = pd.DataFrame([["e", "f", "g"], ["h", "i", "j"]],
                             index=["c2", "c3"],
                             columns=["hd1", "hd2", "hd3"])
        e_concated = pd.DataFrame([["a", "b", np.nan], ["e", "f", "g"],
                                   ["c", "d", np.nan], ["h", "i", "j"]],
                                  index=["c1", "c2", "c2", "c3"],
                                  columns=["hd1", "hd2", "hd3"])

        logger.debug("meta1:\n{}".format(meta1))
        logger.debug("meta2:\n{}".format(meta2))
        logger.debug("e_concated:\n{}".format(e_concated))

        concated = cg.assemble_concatenated_meta([meta2, meta1])
        pd.util.testing.assert_frame_equal(e_concated, concated)