class_docstr: Class for representing hierarchical time series.
  
  The hierarchy is represented by the standard aggregation matrix `S`.
  The time series at the bottom (leaf) level of the hierarchy
  (`ts_at_bottom_level`) are assumed to be given by the columns of
  a single pandas dataframe.
  
  The ordering of columns of `ts_at_bottom_level` should be consistent
  with the ordering of the columns of `S`.
  
  Parameters
  ----------
  ts_at_bottom_level
      A single pandas dataframe whose columns are the time series
      corresponding to the leaves of the hierarchy.
  S
      Summation or aggregation matrix whose ordering should be consistent
      with the ordering of the columns of `ts_at_all_levels`.
      In particular, the bottom `k x k` sub-matrix should be identity matrix,
      where `k` is the number of leaves of the hierarchy.
class_docstr_tok: ["Class","for","representing","hierarchical","time","series",".","The","hierarchy","is","represented","by","the","standard","aggregation","matrix","`","S","`",".","The","time","series","at","the","bottom","(","leaf",")","level","of","the","hierarchy","(","`","ts_at_bottom_level","`",")","are","assumed","to","be","given","by","the","columns","of","a","single","pandas","dataframe",".","The","ordering","of","columns","of","`","ts_at_bottom_level","`","should","be","consistent","with","the","ordering","of","the","columns","of","`","S","`",".","Parameters","--","--","--","--","--","ts_at_bottom_level","A","single","pandas","dataframe","whose","columns","are","the","time","series","corresponding","to","the","leaves","of","the","hierarchy",".","S","Summation","or","aggregation","matrix","whose","ordering","should","be","consistent","with","the","ordering","of","the","columns","of","`","ts_at_all_levels","`",".","In","particular",",","the","bottom","`","k","x","k","`","sub-matrix","should","be","identity","matrix",",","where","`","k","`","is","the","number","of","leaves","of","the","hierarchy","."]
docstr: Convert the hierarchical time series into
  `gluonts.dataset.PandasDataset`.
  
  Note: Currently only dynamic real features are used by the hierarchical
  model. However, the model internally creates a categorical feature
  to distinguish between different time series of the hierarchy.
  
  Parameters
  ----------
  feat_dynamic_real
      A pandas dataframe containing dynamic features as columns.
      Note that features of any (or all) time series in the hierarchy
      can be passed here, since all time series are considered together
      as a single multivariate time series.
  
  Returns
  -------
  PandasDataset
      An instance of `PandasDataset`.
docstr_tok: ["Convert","the","hierarchical","time","series","into","`","gluonts.dataset.PandasDataset","`",".","Note",":","Currently","only","dynamic","real","features","are","used","by","the","hierarchical","model",".","However",",","the","model","internally","creates","a","categorical","feature","to","distinguish","between","different","time","series","of","the","hierarchy",".","Parameters","--","--","--","--","--","feat_dynamic_real","A","pandas","dataframe","containing","dynamic","features","as","columns",".","Note","that","features","of","any","(","or","all",")","time","series","in","the","hierarchy","can","be","passed","here",",","since","all","time","series","are","considered","together","as","a","single","multivariate","time","series",".","Returns","--","--","--","-","PandasDataset","An","instance","of","`","PandasDataset","`","."]
code: def to_dataset(
      self,
      feat_dynamic_real: Optional[pd.DataFrame] = None,
  ):
      """
      Convert the hierarchical time series into
      `gluonts.dataset.PandasDataset`.
  
      Note: Currently only dynamic real features are used by the hierarchical
      model. However, the model internally creates a categorical feature
      to distinguish between different time series of the hierarchy.
  
      Parameters
      ----------
      feat_dynamic_real
          A pandas dataframe containing dynamic features as columns.
          Note that features of any (or all) time series in the hierarchy
          can be passed here, since all time series are considered together
          as a single multivariate time series.
  
      Returns
      -------
      PandasDataset
          An instance of `PandasDataset`.
      """
      future_length = 0
  
      if feat_dynamic_real is not None:
          assert (
              self.ts_at_all_levels.index[0]
              == feat_dynamic_real.index[0]
          ), (
              "The staring time point of dynamic features should match "
              "with that of the hierarchical time series. "
              f"Start of `feat_dynamic_real`: "
              f"{feat_dynamic_real.index[0]} and "
              f"the start of hierarchical time series: "
              f"{self.ts_at_all_levels.index[0]}."
          )
  
          assert feat_dynamic_real.index.intersection(
              self.ts_at_all_levels.index
          ).equals(self.ts_at_all_levels.index), (
              "Dynamic features should be provided for all time "
              "points where the target is defined. "
              f"Index of `feat_dynamic_real`: {feat_dynamic_real.index}, \n"
              f"Index of `ts_at_all_levels` of `hts`: "
              f"{self.ts_at_all_levels.index}. \n "
              "Check if the periods of these indices also match. \n"
          )
  
          feat_dynamic_real.columns = [
              f"feat_dynamic_real_{col}"
              for col in feat_dynamic_real.columns
          ]
          future_length = len(feat_dynamic_real.index) - len(
              self.ts_at_all_levels.index
          )
      else:
          feat_dynamic_real = pd.DataFrame()
  
      pandas_ds = PandasDataset(
          dataframes=pd.concat(
              [self.ts_at_all_levels, feat_dynamic_real],
              axis=1,
          ),
          target=list(self.ts_at_all_levels.columns),
          feat_dynamic_real=list(feat_dynamic_real.columns),
          future_length=future_length,
      )
  
      return pandas_ds
  
file_path: gluonts/src/gluonts/dataset/hierarchical.py
imports: from typing import Optional
  import numpy
  import pandas
  from gluonts.dataset.pandas import PandasDataset
label_desc: Use image node_id 8 for calling the HierarchicalTimeSeries obj's underlying member method code with example usage: obj.to_dataset(feat_dynamic_real) and returns: pandas_ds