def _chunk_dataframe_groups(grouped, chunk_size):
    """chunks a grouped dataframe into groups no larger than chunk_size"""
    for group_key, group_df in grouped:
        for i in range(0, len(group_df), chunk_size):
            yield group_key, group_df.iloc[i:i + chunk_size]
