@@ -0,0 +1,789 @@
+%0Adef groupby(key, iterable, transform=None):%0A    %22%22%22Group items in %60iterable%60 in a dictionary according to %60key%60.%0A%0A    Parameters%0A    ----------%0A    key : function%0A        Returns a hashable when given an item in %60iterable%60.%0A    iterable : tuple, list, generator, or array-like%0A        The items to be grouped.%0A    transform : function, optional%0A        Transform the items before grouping them.%0A%0A    Returns%0A    -------%0A    grouped : dict%0A        A dictionary mapping keys to elements of iterable. This has%0A        the form:%0A            %60%60%7Bkey(elem): %5Btransform(elem)%5D for elem in iterable%7D%60%60%0A    %22%22%22%0A    if transform is None:%0A        transform = lambda x: x%0A    grouped = %7B%7D%0A    for elem in iterable:%0A        grouped.setdefault(key(elem), %5B%5D).append(transform(elem))%0A    return grouped%0A%0A

Add generic groupby function