(table, col_name, added, copied, removed)
return pd.concat([table, new_rows])
Copy and update rows in a table that has a column referencing another
    table that has had rows added via copying.

    Parameters
    ----------
    table : pandas.DataFrame
        Table to update with new or removed rows.
    col_name : str
        Name of column in `table` that corresponds to the index values
        in `copied` and `removed`.
    added : pandas.Index
        Indexes of rows that are new in the linked table.
    copied : pandas.Index
        Indexes of rows that were copied to make new rows in linked table.
    removed : pandas.Index
        Indexes of rows that were removed from the linked table.

    Returns
    -------
    updated : pandas.DataFrame
Copy and update rows in a table that has a column referencing another
    table that has had rows added via copying.
Copy and update rows in a table that has a column referencing another table that has had rows added via copying .
def _update_linked_table(table, col_name, added, copied, removed):
    """
    Copy and update rows in a table that has a column referencing another
    table that has had rows added via copying.

    Parameters
    ----------
    table : pandas.DataFrame
        Table to update with new or removed rows.
    col_name : str
        Name of column in `table` that corresponds to the index values
        in `copied` and `removed`.
    added : pandas.Index
        Indexes of rows that are new in the linked table.
    copied : pandas.Index
        Indexes of rows that were copied to make new rows in linked table.
    removed : pandas.Index
        Indexes of rows that were removed from the linked table.

    Returns
    -------
    updated : pandas.DataFrame

    """
    logger.debug('start: update linked table after transition')

    # handle removals
    table = table.loc[~table[col_name].isin(set(removed))]
    if (added is None or len(added) == 0):
        return table

    # map new IDs to the IDs from which they were copied
    id_map = pd.concat([pd.Series(copied, name=col_name), pd.Series(added, name='temp_id')], axis=1)

    # join to linked table and assign new id
    new_rows = id_map.merge(table, on=col_name)
    new_rows.drop(col_name, axis=1, inplace=True)
    new_rows.rename(columns={'temp_id': col_name}, inplace=True)

    # index the new rows
    starting_index = table.index.values.max() + 1
    new_rows.index = np.arange(starting_index, starting_index + len(new_rows), dtype=np.int)

    logger.debug('finish: update linked table after transition')
    return pd.concat([table, new_rows])
def _update_linked_table ( table , col_name , added , copied , removed ) : logger . debug ( 'start: update linked table after transition' ) # handle removals table = table . loc [ ~ table [ col_name ] . isin ( set ( removed ) ) ] if ( added is None or len ( added ) == 0 ) : return table # map new IDs to the IDs from which they were copied id_map = pd . concat ( [ pd . Series ( copied , name = col_name ) , pd . Series ( added , name = 'temp_id' ) ] , axis = 1 ) # join to linked table and assign new id new_rows = id_map . merge ( table , on = col_name ) new_rows . drop ( col_name , axis = 1 , inplace = True ) new_rows . rename ( columns = { 'temp_id' : col_name } , inplace = True ) # index the new rows starting_index = table . index . values . max ( ) + 1 new_rows . index = np . arange ( starting_index , starting_index + len ( new_rows ) , dtype = np . int ) logger . debug ( 'finish: update linked table after transition' ) return pd . concat ( [ table , new_rows ] )