(data, nrows, accounting_column=None)
return data.loc[data.index.difference(remove_index)], remove_index
Remove a random `nrows` number of rows from a table.

    Parameters
    ----------
    data : DataFrame
    nrows : float
        Number of rows to remove.
    accounting_column: string, optional
        Name of column with accounting totals/quanties to apply towards the control. If not provided
        then row counts will be used for accounting.

    Returns
    -------
    updated : pandas.DataFrame
        Table with random rows removed.
    removed : pandas.Index
        Indexes of the rows removed from the table.
Remove a random `nrows` number of rows from a table.
Remove a random nrows number of rows from a table .
def remove_rows(data, nrows, accounting_column=None):
    """
    Remove a random `nrows` number of rows from a table.

    Parameters
    ----------
    data : DataFrame
    nrows : float
        Number of rows to remove.
    accounting_column: string, optional
        Name of column with accounting totals/quanties to apply towards the control. If not provided
        then row counts will be used for accounting.

    Returns
    -------
    updated : pandas.DataFrame
        Table with random rows removed.
    removed : pandas.Index
        Indexes of the rows removed from the table.

    """
    logger.debug('start: removing {} rows in transition model'.format(nrows))
    nrows = abs(nrows)  # in case a negative number came in
    unit_check = data[accounting_column].sum() if accounting_column else len(data)
    if nrows == 0:
        return data, _empty_index()
    elif nrows > unit_check:
        raise ValueError('Number of rows to remove exceeds number of records in table.')

    remove_rows = sample_rows(nrows, data, accounting_column=accounting_column, replace=False)
    remove_index = remove_rows.index

    logger.debug('finish: removed {} rows in transition model'.format(nrows))
    return data.loc[data.index.difference(remove_index)], remove_index
def remove_rows ( data , nrows , accounting_column = None ) : logger . debug ( 'start: removing {} rows in transition model' . format ( nrows ) ) nrows = abs ( nrows ) # in case a negative number came in unit_check = data [ accounting_column ] . sum ( ) if accounting_column else len ( data ) if nrows == 0 : return data , _empty_index ( ) elif nrows > unit_check : raise ValueError ( 'Number of rows to remove exceeds number of records in table.' ) remove_rows = sample_rows ( nrows , data , accounting_column = accounting_column , replace = False ) remove_index = remove_rows . index logger . debug ( 'finish: removed {} rows in transition model' . format ( nrows ) ) return data . loc [ data . index . difference ( remove_index ) ] , remove_index