(self)
return self.regressors_df
Parse the request for additional regressors and arguments.
        The regressors are expected as a string of pipe separated values.
        e.g. a single entry with three regressors could be '1.2|200|3'
        
        Arguments for the regressors can be passed in a separate string of keyword arguments.
        The keyword and the value should be separated by equals signs, different keywords by commas, and arguments for different regressors by pipe.
        If a single set of arguments is provided (i.e. no pipe characters are found), we apply the same arguments to all regressors.
        e.g. 'prior_scale=10, mode=additive| mode=multiplicative| mode=multiplicative' for specifying different arguments per regressor
              or 'mode=additive' for using the same arguments for all regressors.

        Returns a data frame with the additional regressors.
Parse the request for additional regressors and arguments.
        The regressors are expected as a string of pipe separated values.
        e.g. a single entry with three regressors could be '1.2|200|3'
        
        Arguments for the regressors can be passed in a separate string of keyword arguments.
        The keyword and the value should be separated by equals signs, different keywords by commas, and arguments for different regressors by pipe.
        If a single set of arguments is provided (i.e. no pipe characters are found), we apply the same arguments to all regressors.
        e.g. 'prior_scale=10, mode=additive| mode=multiplicative| mode=multiplicative' for specifying different arguments per regressor
              or 'mode=additive' for using the same arguments for all regressors.
Parse the request for additional regressors and arguments . The regressors are expected as a string of pipe separated values . e . g . a single entry with three regressors could be 1 . 2|200|3 Arguments for the regressors can be passed in a separate string of keyword arguments . The keyword and the value should be separated by equals signs different keywords by commas and arguments for different regressors by pipe . If a single set of arguments is provided ( i . e . no pipe characters are found ) we apply the same arguments to all regressors . e . g . prior_scale = 10 mode = additive| mode = multiplicative| mode = multiplicative for specifying different arguments per regressor or mode = additive for using the same arguments for all regressors .
def _prep_regressors(self):
        """
        Parse the request for additional regressors and arguments.
        The regressors are expected as a string of pipe separated values.
        e.g. a single entry with three regressors could be '1.2|200|3'
        
        Arguments for the regressors can be passed in a separate string of keyword arguments.
        The keyword and the value should be separated by equals signs, different keywords by commas, and arguments for different regressors by pipe.
        If a single set of arguments is provided (i.e. no pipe characters are found), we apply the same arguments to all regressors.
        e.g. 'prior_scale=10, mode=additive| mode=multiplicative| mode=multiplicative' for specifying different arguments per regressor
              or 'mode=additive' for using the same arguments for all regressors.

        Returns a data frame with the additional regressors.
        """

        # Create a Pandas Data Frame with additional regressors and their keyword arguments
        self.regressors_df = pd.DataFrame([(row.duals[0].numData, row.duals[3].strData, row.duals[4].strData) \
            for request_rows in self.request \
                for row in request_rows.rows], \
                    columns=['ds', 'regressors', 'kwargs'])
        
        # Handle null value rows in the request dataset
        self.regressors_df = self.regressors_df.loc[self.regressors_df.ds.notnull()]               
        
        # Check if the regressors column is empty
        if len(self.regressors_df.regressors.unique()) == 1:
            # Return without further processing
            self.has_regressors = False
            if self.debug:
                self._print_log(7)
            return None

        # Get the regressor arguments as a string
        arg_string = self.regressors_df.loc[0, 'kwargs']
        
        # Add kwargs for regressors to a list of dictionaries
        self.regressor_kwargs = []
        for kwargs_string in arg_string.replace(' ', '').split('|'):
            if len(kwargs_string) > 0:
                kwargs = {}
                for kv in kwargs_string.split(','):
                    pair = kv.split('=')
                    if 'prior_scale' in pair[0]:
                        pair[1] = utils.atof(pair[1])
                    if 'standardize' in pair[0] and pair[1].lower() != 'auto':
                        pair[1] = 'true' == pair[1].lower()
                    kwargs[pair[0]] = pair[1]
                self.regressor_kwargs.append(kwargs) 

        # Split up the additional regressors into multiple columns
        self.regressors_df = pd.DataFrame(self.regressors_df.regressors.str.split('|', expand=True).values, \
            index=self.regressors_df.index).add_prefix('regressor_')
        
        # Convert the strings to floats
        self.regressors_df = self.regressors_df.applymap(utils.atof)
        
        # Copy dates from the request_df
        self.regressors_df.loc[:,'ds'] = self.request_df.loc[:,'ds'].copy()

        # Sort by the ds column and reset indexes
        self.regressors_df = self.regressors_df.sort_values('ds').reset_index(drop=True).drop(columns=['ds'])

        # If there are no regressor kwargs add empty dictionaries
        if len(self.regressor_kwargs) == 0:
            self.regressor_kwargs = [{} for c in self.regressors_df.columns]
        # If there is just 1 dictionary, replicate it for each regressor
        elif len(self.regressor_kwargs) == 1:
            kwargs = self.regressor_kwargs[0].copy()
            self.regressor_kwargs = [kwargs for c in self.regressors_df.columns]
        elif len(self.regressor_kwargs) != len(self.regressors_df.columns):
            err = "The number of additional regressors does not match the keyword arguments provided for the regressors."
            raise IndexError(err) 

        return self.regressors_df
def _prep_regressors ( self ) : # Create a Pandas Data Frame with additional regressors and their keyword arguments self . regressors_df = pd . DataFrame ( [ ( row . duals [ 0 ] . numData , row . duals [ 3 ] . strData , row . duals [ 4 ] . strData ) for request_rows in self . request for row in request_rows . rows ] , columns = [ 'ds' , 'regressors' , 'kwargs' ] ) # Handle null value rows in the request dataset self . regressors_df = self . regressors_df . loc [ self . regressors_df . ds . notnull ( ) ] # Check if the regressors column is empty if len ( self . regressors_df . regressors . unique ( ) ) == 1 : # Return without further processing self . has_regressors = False if self . debug : self . _print_log ( 7 ) return None # Get the regressor arguments as a string arg_string = self . regressors_df . loc [ 0 , 'kwargs' ] # Add kwargs for regressors to a list of dictionaries self . regressor_kwargs = [ ] for kwargs_string in arg_string . replace ( ' ' , '' ) . split ( '|' ) : if len ( kwargs_string ) > 0 : kwargs = { } for kv in kwargs_string . split ( ',' ) : pair = kv . split ( '=' ) if 'prior_scale' in pair [ 0 ] : pair [ 1 ] = utils . atof ( pair [ 1 ] ) if 'standardize' in pair [ 0 ] and pair [ 1 ] . lower ( ) != 'auto' : pair [ 1 ] = 'true' == pair [ 1 ] . lower ( ) kwargs [ pair [ 0 ] ] = pair [ 1 ] self . regressor_kwargs . append ( kwargs ) # Split up the additional regressors into multiple columns self . regressors_df = pd . DataFrame ( self . regressors_df . regressors . str . split ( '|' , expand = True ) . values , index = self . regressors_df . index ) . add_prefix ( 'regressor_' ) # Convert the strings to floats self . regressors_df = self . regressors_df . applymap ( utils . atof ) # Copy dates from the request_df self . regressors_df . loc [ : , 'ds' ] = self . request_df . loc [ : , 'ds' ] . copy ( ) # Sort by the ds column and reset indexes self . regressors_df = self . regressors_df . sort_values ( 'ds' ) . reset_index ( drop = True ) . drop ( columns = [ 'ds' ] ) # If there are no regressor kwargs add empty dictionaries if len ( self . regressor_kwargs ) == 0 : self . regressor_kwargs = [ { } for c in self . regressors_df . columns ] # If there is just 1 dictionary, replicate it for each regressor elif len ( self . regressor_kwargs ) == 1 : kwargs = self . regressor_kwargs [ 0 ] . copy ( ) self . regressor_kwargs = [ kwargs for c in self . regressors_df . columns ] elif len ( self . regressor_kwargs ) != len ( self . regressors_df . columns ) : err = "The number of additional regressors does not match the keyword arguments provided for the regressors." raise IndexError ( err ) return self . regressors_df