Ejemplo n.º 1
0
def _load_and_merge_mps(mp_list, store, label_merger, metadata_merger, merge_tasks):
    mp_list = [mp.load_dataframes(store=store) for mp in mp_list]
    mp = MetaPartition.merge_metapartitions(
        mp_list, label_merger=label_merger, metadata_merger=metadata_merger
    )
    mp = mp.concat_dataframes()

    for task in merge_tasks:
        mp = mp.merge_dataframes(**task)

    return mp
Ejemplo n.º 2
0
def test_merge_metapartitions():
    df = pd.DataFrame({"P": [1, 1], "L": [1, 2], "TARGET": [1, 2]})
    df_2 = pd.DataFrame({"P": [1], "info": "a"})
    mp = MetaPartition(label="cluster_1", data={"core": df, "helper": df_2})
    df_3 = pd.DataFrame({"P": [1, 1], "L": [1, 2], "PRED": [0.1, 0.2]})

    mp2 = MetaPartition(label="cluster_1", data={"predictions": df_3})
    merged_mp = MetaPartition.merge_metapartitions(metapartitions=[mp, mp2])

    df = pd.DataFrame({
        "P": [1, 1],
        "L": [1, 2],
        "TARGET": [1, 2],
        "info": ["a", "a"],
        "PRED": [0.1, 0.2],
    })

    assert merged_mp.label == "cluster_1"
    assert len(merged_mp.data) == 3