Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def test_groupby():
names = ['Alice', 'Bob', 'Charlie', 'Dan', 'Edith', 'Frank']
assert groupby(len, names) == {3: ['Bob', 'Dan'],
5: ['Alice', 'Edith', 'Frank'],
7: ['Charlie']}
even = lambda x: x % 2 == 0
assert groupby(even, range(10)) == {False: [1, 3, 5, 7, 9],
True: [0, 2, 4, 6, 8]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment