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])
code: def __init__(self, bins, aggfunc=None, return_index="bin_start"):
      self.bins = bins
      self.aggfunc = aggfunc
      self.return_index = return_index
  
      if not isinstance(bins, pd.IntervalIndex):
          self._bins = pd.IntervalIndex.from_breaks(bins)
      else:
          self._bins = bins
  
      if self.aggfunc is None:
          self._aggfunc = np.mean
      else:
          assert callable(aggfunc), (
              "aggfunc should be callable with" "signature 1D -> float"
          )
          if aggfunc.__name__ == "<lambda>":
              warnings.warn(
                  "Save and load will not work with lambda functions",
                  stacklevel=2,
              )
          self._aggfunc = self.aggfunc
  
      super().__init__()
  
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 1 to create a new TimeBinAggregate object from inherited base classes: BaseTransformer with example: obj = TimeBinAggregate(bins, aggfunc, return_index)