Пример #1
0
def test_union_inner():
    df = pd.DataFrame()
    df["A"] = [1, 2]
    df["B"] = [10, 20]

    df2 = pd.DataFrame()
    df2["A"] = [3, 4]
    df2["C"] = 30, 40

    w = Wrap(df)
    wnew = w.union([df2], kind="inner")

    assert ["A"] == list(wnew.df.columns)
    assert [1, 2, 3, 4] == list(wnew.df["A"])
Пример #2
0
def test_union():
    df = pd.DataFrame()
    df["A"] = [1, 2]
    df["B"] = [10, 20]

    df2 = pd.DataFrame()
    df2["A"] = [3, 4]
    df2["C"] = 30, 40

    w = Wrap(df)
    wnew = w.union([df2])

    assert ["A", "B", "C"] == list(wnew.df.columns)
    assert [1, 2, 3, 4] == list(wnew.df["A"])
    assert [10, 20, -1, -1] == replace_nan(wnew.df["B"], -1)
    assert [-1, -1, 30, 40] == replace_nan(wnew.df["C"], -1)