How to use the flupy.flu.group_by function in flupy

To help you get started, we’ve selected a few flupy 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 olirice / flupy / tests / test_flu.py View on Github external
v2 = flu(range(10)).map(lambda x: (x, [x]))
        assert v1.collect() == v2.collect()
        # Sort
        gen = flu([1, 2, 1, 2]).group_by(lambda x: x, sort=False)
        assert gen.count() == 4
        gen = flu([1, 2, 1, 2]).group_by(lambda x: x, sort=True)
        assert gen.count() == 2

        # Identity Function
        points = [
                {'x': 1, 'y': 0},
                {'x': 4, 'y': 3},
                {'x': 1, 'y': 5}
        ]
        key_func = lambda u: u['x']
        gen = flu.group_by(points, key=key_func, sort=True).collect()
        assert len(gen) == 2
        assert gen[0][0] == 1
        assert gen[1][0] == 4
        assert len(gen[0][1].collect()) == 2
        assert len(gen[1][1].collect()) == 1

flupy

Method chaining built on generators

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis