class_docstr: Bins time series and aggregates by bin.
  
  In `transform`, applies `groupby` with `aggfunc` on the temporal coordinate.
  
  More precisely:
  `bins` encodes bins :math:`B_1, \dots, B_k` where :math:`B_i` are intervals,
  in the reals or in a temporal (time stamp) range.
  
  In `transform`, the estimator `TimeBinAggregate` collects values
  at time stamps of `X` falling into :math:`B_i` as a sample :math:`S_i`,
  and then applies `aggfunc` to :math:`S_i` to obtain an aggregate value :math:`v_i`.
  The transformed series are values :math:`v_i` at time stamps :math:`t_i`,
  determined from :math:`B_i` per the rule in `return_index`.
  
  Parameters
  ----------
  bins : 1D array-like or pd.IntervalIndex
      if 1D array-like, is interpreted as breaks of bins
      breaks of bins defining intervals considered by aggfunc
  aggfunc : callable *1D array-like -> float), optional, default=np.mean
      Function used to aggregate the values in intervals.
      Should have signature 1D -> float and defaults
      to mean if None
  return_index : str, one of the below; optional, default="range"
      "range" = RangeIndex with bins indexed in same order as in `bins`
      "bin_start" = transformed pd.DataFrame will be indexed by bin starts
      "bin_end" = transformed pd.DataFrame will be indexed by bin starts
      "bin_mid" = transformed pd.DataFrame will be indexed by bin midpoints
      "bin" = transformed pd.DataFrame will have `bins` as `IntervalIndex`
  
  Example
  -------
  from sktime.datatypes import get_examples
  from sktime.transformations.series.binning import TimeBinAggregate
  
  bins = [0, 2, 4]
  X = get_examples("pd.DataFrame")[0]
  
  t = TimeBinAggregate([-1, 2, 10])
docstr: Transform X and return a transformed version.
  
  private _transform containing core logic, called from transform
  
  Parameters
  ----------
  X : Series or Panel of mtype X_inner_mtype
      if X_inner_mtype is list, _transform must support all types in it
      Data to be transformed
  y : Series or Panel of mtype y_inner_mtype, default=None
      Additional data, e.g., labels for transformation
  
  Returns
  -------
  transformed version of X
docstr_tok: ["Transform","X","and","return","a","transformed","version",".","private","_transform","containing","core","logic",",","called","from","transform","Parameters","--","--","--","--","--","X",":","Series","or","Panel","of","mtype","X_inner_mtype","if","X_inner_mtype","is","list",",","_transform","must","support","all","types","in","it","Data","to","be","transformed","y",":","Series","or","Panel","of","mtype","y_inner_mtype",",","default=None","Additional","data",",","e.g.",",","labels","for","transformation","Returns","--","--","--","-","transformed","version","of","X"]
code: def _transform(self, X, y=None):
      """Transform X and return a transformed version.
  
      private _transform containing core logic, called from transform
  
      Parameters
      ----------
      X : Series or Panel of mtype X_inner_mtype
          if X_inner_mtype is list, _transform must support all types in it
          Data to be transformed
      y : Series or Panel of mtype y_inner_mtype, default=None
          Additional data, e.g., labels for transformation
  
      Returns
      -------
      transformed version of X
      """
      bins = self.bins
      idx_cut = pd.cut(X.index, bins=self._bins, include_lowest=True)
      Xt = X.groupby(idx_cut).apply(self._aggfunc)
  
      if self.return_index == "range":
          Xt = Xt.reset_index(drop=True)
      elif self.return_index == "bin_start":
          if bins is pd.IntervalIndex:
              Xt.index = [x.left for x in Xt.index]
          else:
              Xt.index = bins[:-1]
      elif self.return_index == "bin_end":
          if bins is pd.IntervalIndex:
              Xt.index = [x.right for x in Xt.index]
          else:
              Xt.index = bins[1:]
      elif self.return_index == "bin_mid":
          if bins is pd.IntervalIndex:
              Xt.index = [(x.left + x.right) / 2 for x in Xt.index]
          else:
              Xt.index = [
                  (bins[i] + bins[i + 1]) / 2 for i in range(len(bins))
              ]
      elif self.return_index == "bin":
          Xt.index = self._bins
      return Xt
  
file_path: sktime/sktime/transformations/series/binning.py
imports: import warnings
  import numpy
  import pandas
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 2 for calling the TimeBinAggregate obj's underlying member method code with example usage: obj._transform(X, y) and returns: Xt