class_docstr: Missing value imputation.
  
  The Imputer transforms input series by replacing missing values according
  to an imputation strategy specified by `method`.
  
  Parameters
  ----------
  method : str, default="drift"
      Method to fill the missing values.
  
      * "drift" : drift/trend values by sktime.PolynomialTrendForecaster(degree=1)
          first, X in transform() is filled with ffill then bfill
          then PolynomialTrendForecaster(degree=1) is fitted to filled X, and
          predict values are queried at indices which had missing values
      * "linear" : linear interpolation, uses pd.Series.interpolate()
          WARNING: This method can not extrapolate, so it is fitted always on the
          data given to transform().
      * "nearest" : use nearest value, uses pd.Series.interpolate()
      * "constant" : same constant value (given in arg value) for all NaN
      * "mean" : pd.Series.mean() of *fit* data
      * "median" : pd.Series.median() of *fit* data
      * "backfill" to "bfill" : adapted from pd.Series.fillna()
      * "pad" or "ffill" : adapted from pd.Series.fillna()
      * "random" : random values between pd.Series.min() and .max() of *fit* data
          if pd.Series dtype is int, sample is uniform discrete
          if pd.Series dtype is float, sample is uniform continuous
      * "forecaster" : use an sktime Forecaster, given in param forecaster.
          First, X in *fit* is filled with ffill then bfill
          then forecaster is fitted to filled X, and *predict* values are queried
          at indices of X data in *transform* which had missing values
      For the following methods, the train data is used to fit them:
      "drift", "mean", "median", "random". For all other methods, the
      transform data is sufficient to compute the impute values.
  
  missing_values : int/float/str, default=None
      The placeholder for the missing values. All occurrences of
      missing_values will be imputed, in addition to np.nan.
      If None, then only np.nan values are imputed.
  value : int/float, default=None
      Value to use to fill missing values when method="constant".
  forecaster : Any Forecaster based on sktime.BaseForecaster, default=None
      Use a given Forecaster to impute by insample predictions when
      method="forecaster". Before fitting, missing data is imputed with
      method="ffill" or "bfill" as heuristic. in case of multivariate X,
      the forecaster is applied separate to each column like a
      ColumnEnsembleForecaster.
  random_state : int/float/str, optional
      Value to set random.seed() if method="random", default None
  
  Examples
  --------
  >>> from sktime.transformations.series.impute import Imputer
  >>> from sktime.datasets import load_airline
  >>> from sktime.split import temporal_train_test_split
  >>> y = load_airline()
  >>> y_train, y_test = temporal_train_test_split(y)
  >>> transformer = Imputer(method="drift")
  >>> transformer.fit(y_train)
  Imputer(...)
  >>> y_test.iloc[3] = np.nan
  >>> y_hat = transformer.transform(y_test)
docstr: Use a given forecaster for imputation by in-sample predictions.
  
  Parameters
  ----------
  X : pd.DataFrame
      Series to impute.
  y : pd.DataFrame
      Exog data for forecaster.
  
  Returns
  -------
  Xt : pd.DataFrame
      Series with imputed values.
docstr_tok: ["Use","a","given","forecaster","for","imputation","by","in-sample","predictions",".","Parameters","--","--","--","--","--","X",":","pd.DataFrame","Series","to","impute",".","y",":","pd.DataFrame","Exog","data","for","forecaster",".","Returns","--","--","--","-","Xt",":","pd.DataFrame","Series","with","imputed","values","."]
code: def _impute_with_forecaster(self, X, y):
      """Use a given forecaster for imputation by in-sample predictions.
  
      Parameters
      ----------
      X : pd.DataFrame
          Series to impute.
      y : pd.DataFrame
          Exog data for forecaster.
  
      Returns
      -------
      Xt : pd.DataFrame
          Series with imputed values.
      """
      for col in X.columns:
          if _has_missing_values(X[col]):
              # define fh based on index of missing values
              na_index = X[col].index[X[col].isna()]
              fh = ForecastingHorizon(
                  values=na_index, is_relative=False
              )
  
              # fill NaN before fitting with ffill and backfill (heuristic)
  
              self._forecaster.fit(
                  y=self._X[col].ffill().bfill(),
                  X=self._y[col].ffill().bfill()
                  if self._y is not None
                  else None,
                  fh=fh,
              )
  
              # replace missing values with predicted values
              X[col][na_index] = self._forecaster.predict(fh=fh, X=y)
      return X
  
file_path: sktime/sktime/transformations/series/impute.py
imports: import numpy
  import pandas
  from sklearn.utils import check_random_state
  from sktime.forecasting.base import ForecastingHorizon
  from sktime.forecasting.trend import PolynomialTrendForecaster
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 6 for calling the Imputer obj's underlying member method code with example usage: obj._impute_with_forecaster(X, y) and returns: X