code: def bestfit(self):
      """
      Returns a series with the bestfit values.
  
      Example:
              Series.bestfit()
  
      Returns: series
              The returned series contains a parameter
              called 'formula' which includes the string representation
              of the bestfit line.
      """
      # statsmodel cannot be included on requirements.txt
      # see https://github.com/scikit-learn/scikit-learn/issues/4164
      # which shares the same issue as statsmodel
      try:
          import statsmodels.api as sm
      except:
          raise Exception(
              "statsmodels is required: "
              "please run "
              "pip install statsmodels"
          )
  
      if isinstance(self.index, pd.DatetimeIndex):
          x = pd.Series(list(range(1, len(self) + 1)), index=self.index)
      else:
          x = self.index.values
  
      x = sm.add_constant(x)
      model = sm.OLS(self, x)
      fit = model.fit()
      vals = fit.params.values
      best_fit = fit.fittedvalues
      # the below methods have been deprecated in Pandas
      # model=pd.ols(x=x,y=self,intercept=True)
      # best_fit=model.y_fitted
      best_fit.formula = "%.2f*x+%.2f" % (vals[1], vals[0])
      return best_fit
  
imports: import pandas
  import re
label_desc: Use image node_id 3 for calling a global function with example usage: bestfit() and returns: best_fit