code: def load_from_pandas(
      df: pd.DataFrame,
      time_index: pd.PeriodIndex,
      agg_freq: Optional[str] = None,
  ) -> List[pd.Series]:
      df: pd.DataFrame = df.set_index(time_index)
  
      pivot_df = df.transpose()
      pivot_df.head()
  
      timeseries = []
      for row in pivot_df.iterrows():
          ts = pd.Series(row[1].values, index=time_index)
          if agg_freq is not None:
              ts = ts.resample(agg_freq).sum()
          first_valid = ts[ts.notnull()].index[0]
          last_valid = ts[ts.notnull()].index[-1]
          ts = ts[first_valid:last_valid]
  
          timeseries.append(ts)
  
      return timeseries
  
file_path: gluonts/src/gluonts/dataset/repository/_lstnet.py
imports: from pathlib import Path
  from typing import List, NamedTuple, Optional, cast
  import pandas
  from gluonts.dataset import DatasetWriter
  from gluonts.dataset.common import MetaData, TrainDatasets
  from gluonts.dataset.repository._util import metadata
label_desc: Use image node_id 1 for calling a global function with example usage: load_from_pandas(df, time_index, agg_freq) and returns: timeseries