Example #1
0
def test_join_on_fullouter_step(startrek_starships, startrek_starships_specs):
    """
    Full outer Join with NA mismmatches
    """
    recipe = Recipe([
        JoinStep(startrek_starships_specs, by="uid", how="full"),
        SortStep('uid')
    ])
    baked_data = recipe.prepare(startrek_starships).bake(startrek_starships)

    assert baked_data.shape == (5, 3)
    row = pd.Series({'uid': 'NCC-1031', 'name': 'USS Discovery', 'warp': 9.9}, name=0)
    assert_series_equal(baked_data.loc[0], row)
    row = pd.Series({'uid': 'NX-01', 'name': 'Enterprise', 'warp': None}, name=4)
    assert_series_equal(baked_data.loc[4], row)
Example #2
0
def test_join_on_right_step(startrek_starships, startrek_starships_specs):
    """
    Right Join with NA mismmatches
    """
    recipe = Recipe([
        JoinStep(startrek_starships_specs, by="uid", how="right"),
        SortStep('uid')
    ])
    baked_data = recipe.prepare(startrek_starships).bake(startrek_starships)

    assert baked_data.shape == (4, 3)
    row = pd.Series({'uid': 'NCC-1031', 'name': 'USS Discovery', 'warp': 9.9}, name=0)
    assert_series_equal(baked_data.loc[0], row)
    row = pd.Series({'uid': 'NCC-74656', 'name': 'USS Voyager', 'warp': 9.975}, name=3)
    assert_series_equal(baked_data.loc[3], row)
Example #3
0
def test_inner_join_step(startrek_starships, startrek_starships_specs):
    """
    Inner Join with NA mismmatches
    """
    recipe = Recipe(
        [InnerJoinStep(startrek_starships_specs, by="uid"),
         SortStep('uid')])
    bdf = recipe.prepare(startrek_starships).bake(startrek_starships)

    assert bdf.shape == (4, 3)
    row = pd.Series({
        'uid': 'NCC-1031',
        'name': 'USS Discovery',
        'warp': 9.9
    },
                    name=0)
    assert_series_equal(bdf.loc[0], row)
    row = pd.Series({
        'uid': 'NCC-74656',
        'name': 'USS Voyager',
        'warp': 9.975
    },
                    name=3)
    assert_series_equal(bdf.loc[3], row)