(self, data, year)
return updated, added_indexes, copied_indexes, removed_indexes
Add or remove rows to/from a table according to the prescribed
        growth rate for this model and year.

        Parameters
        ----------
        data : pandas.DataFrame
            Rows will be removed from or added to this table.
        year : None, optional
            Here for compatibility with other transition models,
            but ignored.

        Returns
        -------
        updated : pandas.DataFrame
            Table with rows removed or added.
        added : pandas.Index
            New indexes of the rows that were added.
        copied : pandas.Index
            Indexes of rows that were copied. A row copied multiple times
            will have multiple entries.
        removed : pandas.Index
            Index of rows that were removed.
Add or remove rows to/from a table according to the prescribed
        growth rate for this model and year.
Add or remove rows to / from a table according to the prescribed growth rate for this model and year .
def transition(self, data, year):
        """
        Add or remove rows to/from a table according to the prescribed
        growth rate for this model and year.

        Parameters
        ----------
        data : pandas.DataFrame
            Rows will be removed from or added to this table.
        year : None, optional
            Here for compatibility with other transition models,
            but ignored.

        Returns
        -------
        updated : pandas.DataFrame
            Table with rows removed or added.
        added : pandas.Index
            New indexes of the rows that were added.
        copied : pandas.Index
            Indexes of rows that were copied. A row copied multiple times
            will have multiple entries.
        removed : pandas.Index
            Index of rows that were removed.

        """
        logger.debug('start: tabular transition')
        if year not in self._config_table.index:
            raise ValueError('No targets for given year: {}'.format(year))

        # want this to be a DataFrame
        year_config = self._config_table.loc[[year]]
        logger.debug('transitioning {} segments'.format(len(year_config)))

        segments = []
        added_indexes = []
        copied_indexes = []
        removed_indexes = []

        # since we're looping over discrete segments we need to track
        # out here where their new indexes will begin
        starting_index = data.index.values.max() + 1

        for _, row in year_config.iterrows():
            subset = util.filter_table(data, row, ignore={self._config_column})

            # Do not run on segment if it is empty
            if len(subset) == 0:
                logger.debug('empty segment encountered')
                continue

            if self.accounting_column is None:
                nrows = self._calc_nrows(len(subset), row[self._config_column])
            else:
                nrows = self._calc_nrows(
                    subset[self.accounting_column].sum(),
                    row[self._config_column])

            updated, added, copied, removed = \
                add_or_remove_rows(subset, nrows, starting_index, self.accounting_column)
            if nrows > 0:
                # only update the starting index if rows were added
                starting_index = starting_index + nrows
            segments.append(updated)
            added_indexes.append(added)
            copied_indexes.append(copied)
            removed_indexes.append(removed)

        updated = pd.concat(segments)
        added_indexes = util.concat_indexes(added_indexes)
        copied_indexes = util.concat_indexes(copied_indexes)
        removed_indexes = util.concat_indexes(removed_indexes)

        logger.debug('finish: tabular transition')
        return updated, added_indexes, copied_indexes, removed_indexes
def transition ( self , data , year ) : logger . debug ( 'start: tabular transition' ) if year not in self . _config_table . index : raise ValueError ( 'No targets for given year: {}' . format ( year ) ) # want this to be a DataFrame year_config = self . _config_table . loc [ [ year ] ] logger . debug ( 'transitioning {} segments' . format ( len ( year_config ) ) ) segments = [ ] added_indexes = [ ] copied_indexes = [ ] removed_indexes = [ ] # since we're looping over discrete segments we need to track # out here where their new indexes will begin starting_index = data . index . values . max ( ) + 1 for _ , row in year_config . iterrows ( ) : subset = util . filter_table ( data , row , ignore = { self . _config_column } ) # Do not run on segment if it is empty if len ( subset ) == 0 : logger . debug ( 'empty segment encountered' ) continue if self . accounting_column is None : nrows = self . _calc_nrows ( len ( subset ) , row [ self . _config_column ] ) else : nrows = self . _calc_nrows ( subset [ self . accounting_column ] . sum ( ) , row [ self . _config_column ] ) updated , added , copied , removed = add_or_remove_rows ( subset , nrows , starting_index , self . accounting_column ) if nrows > 0 : # only update the starting index if rows were added starting_index = starting_index + nrows segments . append ( updated ) added_indexes . append ( added ) copied_indexes . append ( copied ) removed_indexes . append ( removed ) updated = pd . concat ( segments ) added_indexes = util . concat_indexes ( added_indexes ) copied_indexes = util . concat_indexes ( copied_indexes ) removed_indexes = util . concat_indexes ( removed_indexes ) logger . debug ( 'finish: tabular transition' ) return updated , added_indexes , copied_indexes , removed_indexes