def data_merge_by_batch(parent_directory, verbose=True):
    'Merge a set of parameters.csv files into one.\n\n    This is intended for use with batch processes from Legion, with each batch\n    being 1000 runs longand numbered with integer values.\n\n    Parameters\n    ----------\n    parent_directory : :obj:`list` of :obj:`str`\n        Parent directory to a set of directories each containing model runs and\n        a parameters.csv file.\n    verbose : :obj:`boolean`, optional\n        Boolean indicator of whether to print extra information.\n\n    Returns\n    -------\n    None\n        Concatenated will be written to file in `parent_directory`\n\n    '
    dirs = [os.path.abspath(os.path.join(parent_directory, d)) for d in os.listdir(parent_directory) if (os.path.isdir(os.path.abspath(os.path.join(parent_directory, d))) and (d != 'archives'))]
    dirs = sort_human(dirs)
    if verbose:
        print(dirs)
    dfs = []
    for d in dirs:
        try:
            dfs.append(pd.read_csv(os.path.join(d, 'parameters.csv')))
            ii = (len(dfs) - 1)
            print('Processing parameter file {}'.format(ii))
            if (ii is not 0):
                dfs[ii]['ix'] = ((dfs[ii].index.values + dfs[(ii - 1)]['ix'].values[(- 1)]) + 1)
            else:
                dfs[ii]['ix'] = dfs[ii].index.values
            if os.path.split(d)[1].split('_')[(- 1)].isdigit():
                print(os.path.split(d)[1].split('_')[(- 1)])
                dfs[ii]['Batch'] = int(os.path.split(d)[1].split('_')[(- 1)])
            else:
                print('Batch number not found for {}'.format(d))
                continue
        except FileNotFoundError:
            print('No parameters file in {}'.format(d))
            continue
    if verbose:
        print('{} dataframes  to be joined'.format(len(dfs)))
    df = pd.concat(dfs)
    df.index = range(len(df))
    output_file = os.path.join(parent_directory, 'all_parameters.csv')
    df.to_csv(output_file, index=False)
    return output_file
Merge a set of parameters.csv files into one.

This is intended for use with batch processes from Legion, with each batch
being 1000 runs longand numbered with integer values.

Parameters
----------
parent_directory : :obj:`list` of :obj:`str`
    Parent directory to a set of directories each containing model runs and
    a parameters.csv file.
verbose : :obj:`boolean`, optional
    Boolean indicator of whether to print extra information.

Returns
-------
None
    Concatenated will be written to file in `parent_directory`
def data_merge_by_batch(parent_directory, verbose=True):
    'Merge a set of parameters.csv files into one.\n\n    This is intended for use with batch processes from Legion, with each batch\n    being 1000 runs longand numbered with integer values.\n\n    Parameters\n    ----------\n    parent_directory : :obj:`list` of :obj:`str`\n        Parent directory to a set of directories each containing model runs and\n        a parameters.csv file.\n    verbose : :obj:`boolean`, optional\n        Boolean indicator of whether to print extra information.\n\n    Returns\n    -------\n    None\n        Concatenated will be written to file in `parent_directory`\n\n    '
    dirs = [os.path.abspath(os.path.join(parent_directory, d)) for d in os.listdir(parent_directory) if (os.path.isdir(os.path.abspath(os.path.join(parent_directory, d))) and (d != 'archives'))]
    dirs = sort_human(dirs)
    if verbose:
        print(dirs)
    dfs = []
    for d in dirs:
        try:
            dfs.append(pd.read_csv(os.path.join(d, 'parameters.csv')))
            ii = (len(dfs) - 1)
            print('Processing parameter file {}'.format(ii))
            if (ii is not 0):
                dfs[ii]['ix'] = ((dfs[ii].index.values + dfs[(ii - 1)]['ix'].values[(- 1)]) + 1)
            else:
                dfs[ii]['ix'] = dfs[ii].index.values
            if os.path.split(d)[1].split('_')[(- 1)].isdigit():
                print(os.path.split(d)[1].split('_')[(- 1)])
                dfs[ii]['Batch'] = int(os.path.split(d)[1].split('_')[(- 1)])
            else:
                print('Batch number not found for {}'.format(d))
                continue
        except FileNotFoundError:
            print('No parameters file in {}'.format(d))
            continue
    if verbose:
        print('{} dataframes  to be joined'.format(len(dfs)))
    df = pd.concat(dfs)
    df.index = range(len(df))
    output_file = os.path.join(parent_directory, 'all_parameters.csv')
    df.to_csv(output_file, index=False)
    return output_file