def group(iterable, n_groups):
    """Group a list into a list of lists

    This function can be used to split up a big list items into a set to be
    processed by each worker in an MPI scheme.

    Parameters
    ----------
    iterable : array_like
        A list of elements
    n_groups : int
        The number of groups you'd like to make

    Returns
    -------
    groups : list
        A list of lists, where each element in `groups` is a list of
        approximately `len(iterable) / n_groups` elements from `iterable`

    See Also
    --------
    interweave : inverse of this operation
    """
    return [iterable[i::n_groups] for i in range(n_groups)]