import six


def _partition_data(data, max_rows):
    """
    Partition a table's data, each partition
    containing at most ``max_rows`` rows.

    :param data: the table data
    :type data: ``list`` of ``list``
    :param max_rows: the maximum number of rows in each partition
    :type max_rows: ``int``
    :return: a generator yielding each new partition
    :rtype: ``generator``
    """
    return (
        data[row:row + max_rows]
        for row in six.moves.range(0, len(data), max_rows)
    )