class_docstr: Column selection transformer.
  
  In transform, subsets `X` to `columns` provided as hyper-parameters.
  
  Sequence of columns in `Xt=transform(X)` is as in `columns` hyper-parameter.
  Caveat: this means that `transform` may change sequence of columns,
      even if no columns are removed from `X` in `transform(X)`.
  
  Parameters
  ----------
  columns : pandas compatible index or index coercible, optional, default = None
      columns to which X in transform is to be subset
  integer_treatment : str, optional, one of "col" (default) and "coerce"
      determines how integer index columns are treated
      "col" = subsets by column iloc index, even if columns is not in X.columns
      "coerce" = coerces to integer pandas.Index and attempts to subset
  index_treatment : str, optional, one of "remove" (default) or "keep"
      determines which column are kept in `Xt = transform(X, y)`
      "remove" = only indices that appear in both X and columns are present in Xt.
      "keep" = all indices in columns appear in Xt. If not present in X, NA is filled.
  
  Examples
  --------
  >>> from sktime.transformations.series.subset import ColumnSelect
  >>> from sktime.datasets import load_longley
  >>> X = load_longley()[1]
  >>> transformer =  ColumnSelect(columns=["GNPDEFL", "POP", "FOO"])
  >>> X_subset = transformer.fit_transform(X=X)
docstr: Transform X and return a transformed version.
  
  private _transform containing the core logic, called from transform
  
  Parameters
  ----------
  X : pd.DataFrame
      Data to be transformed
  y : Ignored argument for interface compatibility
  
  Returns
  -------
  Xt : pd.DataFrame
      transformed version of X
code: def _transform(self, X, y=None):
      """Transform X and return a transformed version.
  
      private _transform containing the core logic, called from transform
  
      Parameters
      ----------
      X : pd.DataFrame
          Data to be transformed
      y : Ignored argument for interface compatibility
  
      Returns
      -------
      Xt : pd.DataFrame
          transformed version of X
      """
      columns = self.columns
      integer_treatment = self.integer_treatment
      index_treatment = self.index_treatment
  
      if columns is None:
          return X
      if pd.api.types.is_scalar(columns):
          columns = [columns]
  
      columns = pd.Index(columns)
  
      if integer_treatment == "col" and pd.api.types.is_integer_dtype(
          columns
      ):
          columns = [x for x in columns if x < len(X.columns)]
          col_idx = X.columns[columns]
          return X[col_idx]
  
      in_cols = columns.isin(X.columns)
      col_X_and_cols = columns[in_cols]
  
      if index_treatment == "remove":
          Xt = X[col_X_and_cols]
      elif index_treatment == "keep":
          Xt = X.reindex(columns=columns)
      else:
          raise ValueError(
              f'index_treatment must be one of "remove", "keep", but found'
              f' "{index_treatment}"'
          )
      return Xt
  
file_path: sktime/sktime/transformations/series/subset.py
imports: import pandas
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 2 for calling the ColumnSelect obj's underlying member method code with example usage: obj._transform(X, y) and returns: Xt, X, X