How to use the pandarallel.utils.inliner.key2value function in pandarallel

To help you get started, we’ve selected a few pandarallel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nalepae / pandarallel / tests / test_inliner.py View on Github external
def test_key2value():
    sources = ("a", "b", "d", "hello")
    sources_duplicate = ("a", "b", "d", "hello", "b")

    dests = (54, "e", 2)
    dests_duplicate = (54, "e", 2, "e")

    source2dest = {"b": 55, "hello": "world"}
    source2dest_with_extra_key = {"b": 55, "hello": "world", "toto": 4}

    expected_result = (("a", "d"), (54, "e", 2, 55, "world"), {1: 3, 3: 4})

    with pytest.raises(ValueError):
        inliner.key2value(sources_duplicate, dests, source2dest)

    with pytest.raises(ValueError):
        inliner.key2value(sources, dests_duplicate, source2dest)

    with pytest.raises(ValueError):
        inliner.key2value(sources, dests, source2dest_with_extra_key)

    assert inliner.key2value(sources, dests, source2dest) == expected_result
github nalepae / pandarallel / tests / test_inliner.py View on Github external
sources = ("a", "b", "d", "hello")
    sources_duplicate = ("a", "b", "d", "hello", "b")

    dests = (54, "e", 2)
    dests_duplicate = (54, "e", 2, "e")

    source2dest = {"b": 55, "hello": "world"}
    source2dest_with_extra_key = {"b": 55, "hello": "world", "toto": 4}

    expected_result = (("a", "d"), (54, "e", 2, 55, "world"), {1: 3, 3: 4})

    with pytest.raises(ValueError):
        inliner.key2value(sources_duplicate, dests, source2dest)

    with pytest.raises(ValueError):
        inliner.key2value(sources, dests_duplicate, source2dest)

    with pytest.raises(ValueError):
        inliner.key2value(sources, dests, source2dest_with_extra_key)

    assert inliner.key2value(sources, dests, source2dest) == expected_result
github nalepae / pandarallel / tests / test_inliner.py View on Github external
dests = (54, "e", 2)
    dests_duplicate = (54, "e", 2, "e")

    source2dest = {"b": 55, "hello": "world"}
    source2dest_with_extra_key = {"b": 55, "hello": "world", "toto": 4}

    expected_result = (("a", "d"), (54, "e", 2, 55, "world"), {1: 3, 3: 4})

    with pytest.raises(ValueError):
        inliner.key2value(sources_duplicate, dests, source2dest)

    with pytest.raises(ValueError):
        inliner.key2value(sources, dests_duplicate, source2dest)

    with pytest.raises(ValueError):
        inliner.key2value(sources, dests, source2dest_with_extra_key)

    assert inliner.key2value(sources, dests, source2dest) == expected_result
github nalepae / pandarallel / tests / test_inliner.py View on Github external
source2dest = {"b": 55, "hello": "world"}
    source2dest_with_extra_key = {"b": 55, "hello": "world", "toto": 4}

    expected_result = (("a", "d"), (54, "e", 2, 55, "world"), {1: 3, 3: 4})

    with pytest.raises(ValueError):
        inliner.key2value(sources_duplicate, dests, source2dest)

    with pytest.raises(ValueError):
        inliner.key2value(sources, dests_duplicate, source2dest)

    with pytest.raises(ValueError):
        inliner.key2value(sources, dests, source2dest_with_extra_key)

    assert inliner.key2value(sources, dests, source2dest) == expected_result