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: Fit transformer to X and y.
  
  private _fit containing the core logic, called from fit
  
  Parameters
  ----------
  X : Series or Panel of mtype X_inner_mtype
      if X_inner_mtype is list, _fit must support all types in it
      Data to fit transform to
  y : Series or Panel of mtype y_inner_mtype, default=None
      Additional data, e.g., labels for transformation
  
  Returns
  -------
  self: reference to self
docstr_tok: ["Fit","transformer","to","X","and","y.","private","_fit","containing","the","core","logic",",","called","from","fit","Parameters","--","--","--","--","--","X",":","Series","or","Panel","of","mtype","X_inner_mtype","if","X_inner_mtype","is","list",",","_fit","must","support","all","types","in","it","Data","to","fit","transform","to","y",":","Series","or","Panel","of","mtype","y_inner_mtype",",","default=None","Additional","data",",","e.g.",",","labels","for","transformation","Returns","--","--","--","-","self",":","reference","to","self"]
code: def _fit(self, X, y=None):
      """Fit transformer to X and y.
  
      private _fit containing the core logic, called from fit
  
      Parameters
      ----------
      X : Series or Panel of mtype X_inner_mtype
          if X_inner_mtype is list, _fit must support all types in it
          Data to fit transform to
      y : Series or Panel of mtype y_inner_mtype, default=None
          Additional data, e.g., labels for transformation
  
      Returns
      -------
      self: reference to self
      """
      self._check_method()
      # all methods of Imputer that are actually doing a fit are
      # implemented here. Some methods don't need to fit, so they are just
      # implemented in _transform
  
      index = X.index
      if isinstance(index, pd.MultiIndex):
          X_grouped = X.groupby(level=list(range(index.nlevels - 1)))
          if self.method == "mean":
              self._mean = X_grouped.mean()
          elif self.method == "median":
              self._median = X_grouped.median()
      else:
          if self.method in ["drift", "forecaster"]:
              self._y = y.copy() if y is not None else None
              if self.method == "drift":
                  self._forecaster = PolynomialTrendForecaster(degree=1)
              elif self.method == "forecaster":
                  self._forecaster = self.forecaster.clone()
          elif self.method == "mean":
              self._mean = X.mean()
          elif self.method == "median":
              self._median = X.median()
  
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 2 for calling the Imputer obj's underlying member method code with example usage: obj._fit(X, y) without return types