docstr: A customized TorchDataset for rolling dataframe for time series applications.
  
  :param df: The dataframe to roll on. The dataframe could contain single id value or
      multiple id values. If the dataframe contains multiple ids, the rows of same id
      should be consecutive. And dataframe should have been ordered by timestamp for each id.
  :param dt_col: a str indicates the col name of datetime column in the input data frame, the
      dt_col must be sorted from past to latest respectively for each id.
  :param freq: The freq(interval) of this dataset, it is normal if freq is None,
      which means that we can not determine the frequency of this dataset. This parameter is
      needed when time_enc is True(for autoformer).
  :param lookback: the length of the past sequence
  :param horizon: int or list,
     if `horizon` is an int, we will sample `horizon` step
     continuously after the forecasting point.
     if `horizon` is an list, we will sample discretely according
     to the input list. 1 means the timestamp just after the observed data.
  :param feature_col: list, indicate the feature col name.
  :param target_col: list, indicate the target col name.
  :param id_col: (optional) a str indicates the col name of dataframe id.
  :param time_enc: bool,
         This parameter should be set to True only when you are using Autoformer model. With
         time_enc to be true, 2 additional numpy ndarray will be returned when you call
         `.to_numpy()`. Be sure to have a time type for dt_col if you set time_enc to True.
  :param label_len: int,
         This parameter should be set to True only when you are using Autoformer model. This
         indicates the length of overlap area of output(y) and input(x) on time axis.
  :param is_predict: bool,
         This parameter indicates if the dataset will be sampled as a prediction dataset
         (without groud truth).
  
  :return:
docstr_tok: ["A","customized","TorchDataset","for","rolling","dataframe","for","time","series","applications",".",":","param","df",":","The","dataframe","to","roll","on",".","The","dataframe","could","contain","single","id","value","or","multiple","id","values",".","If","the","dataframe","contains","multiple","ids",",","the","rows","of","same","id","should","be","consecutive",".","And","dataframe","should","have","been","ordered","by","timestamp","for","each","id",".",":","param","dt_col",":","a","str","indicates","the","col","name","of","datetime","column","in","the","input","data","frame",",","the","dt_col","must","be","sorted","from","past","to","latest","respectively","for","each","id",".",":","param","freq",":","The","freq","(","interval",")","of","this","dataset",",","it","is","normal","if","freq","is","None",",","which","means","that","we","can","not","determine","the","frequency","of","this","dataset",".","This","parameter","is","needed","when","time_enc","is","True","(","for","autoformer",")",".",":","param","lookback",":","the","length","of","the","past","sequence",":","param","horizon",":","int","or","list",",","if","`","horizon","`","is","an","int",",","we","will","sample","`","horizon","`","step","continuously","after","the","forecasting","point",".","if","`","horizon","`","is","an","list",",","we","will","sample","discretely","according","to","the","input","list",".","1","means","the","timestamp","just","after","the","observed","data",".",":","param","feature_col",":","list",",","indicate","the","feature","col","name",".",":","param","target_col",":","list",",","indicate","the","target","col","name",".",":","param","id_col",":","(","optional",")","a","str","indicates","the","col","name","of","dataframe","id",".",":","param","time_enc",":","bool",",","This","parameter","should","be","set","to","True","only","when","you","are","using","Autoformer","model",".","With","time_enc","to","be","true",",","2","additional","numpy","ndarray","will","be","returned","when","you","call","`",".to_numpy","(",")","`",".","Be","sure","to","have","a","time","type","for","dt_col","if","you","set","time_enc","to","True",".",":","param","label_len",":","int",",","This","parameter","should","be","set","to","True","only","when","you","are","using","Autoformer","model",".","This","indicates","the","length","of","overlap","area","of","output","(","y",")","and","input","(","x",")","on","time","axis",".",":","param","is_predict",":","bool",",","This","parameter","indicates","if","the","dataset","will","be","sampled","as","a","prediction","dataset","(","without","groud","truth",")",".",":","return",":"]
code: def __init__(
      self,
      df,
      dt_col,
      freq,
      lookback,
      horizon,
      feature_col,
      target_col,
      id_col=None,
      time_enc=False,
      label_len=0,
      is_predict=False,
  ):
      """
      A customized TorchDataset for rolling dataframe for time series applications.
  
      :param df: The dataframe to roll on. The dataframe could contain single id value or
          multiple id values. If the dataframe contains multiple ids, the rows of same id
          should be consecutive. And dataframe should have been ordered by timestamp for each id.
      :param dt_col: a str indicates the col name of datetime column in the input data frame, the
          dt_col must be sorted from past to latest respectively for each id.
      :param freq: The freq(interval) of this dataset, it is normal if freq is None,
          which means that we can not determine the frequency of this dataset. This parameter is
          needed when time_enc is True(for autoformer).
      :param lookback: the length of the past sequence
      :param horizon: int or list,
         if `horizon` is an int, we will sample `horizon` step
         continuously after the forecasting point.
         if `horizon` is an list, we will sample discretely according
         to the input list. 1 means the timestamp just after the observed data.
      :param feature_col: list, indicate the feature col name.
      :param target_col: list, indicate the target col name.
      :param id_col: (optional) a str indicates the col name of dataframe id.
      :param time_enc: bool,
             This parameter should be set to True only when you are using Autoformer model. With
             time_enc to be true, 2 additional numpy ndarray will be returned when you call
             `.to_numpy()`. Be sure to have a time type for dt_col if you set time_enc to True.
      :param label_len: int,
             This parameter should be set to True only when you are using Autoformer model. This
             indicates the length of overlap area of output(y) and input(x) on time axis.
      :param is_predict: bool,
             This parameter indicates if the dataset will be sampled as a prediction dataset
             (without groud truth).
  
      :return:
  
      """
      # horizon_time is only for time_enc, the time_enc numpy ndarray won't have any
      # shape change when the dataset is for prediction.
      self.horizon_time = horizon
      if horizon == 0:
          is_predict = True
      if is_predict:
          horizon = 0
  
      df.reset_index(drop=True, inplace=True)
      feature_col = _to_list(feature_col, "feature_col")
      target_col = _to_list(target_col, "target_col")
      _check_cols_no_na(df, col_names=target_col + feature_col)
      cols = target_col + feature_col
      cols = cols[0] if len(cols) == 1 else cols
      self.arr = df.loc[:, cols].to_numpy()
      self.arr = (
          np.expand_dims(self.arr, axis=1)
          if self.arr.ndim == 1
          else self.arr
      )
      max_horizon = (
          horizon if isinstance(horizon, int) else max(horizon)
      )
      window_size = lookback + max_horizon
      self.roll_start_idxes = get_roll_start_idx(
          df, id_col, window_size=window_size
      )
      self.lookback = lookback
      self.horizon = horizon
      self.target_num = len(target_col)
      self.is_predict = is_predict
  
      # time_enc
      self.time_enc = time_enc
      self.label_len = label_len
      if self.time_enc:
          df_stamp = pd.DataFrame(columns=[dt_col])
          if is_predict:
              pred_dates = pd.date_range(
                  df[dt_col].values[-1],
                  periods=self.horizon_time + 1,
                  freq=freq,
              )
              df_stamp.loc[:, dt_col] = list(df[dt_col].values) + list(
                  pred_dates[1:]
              )
          else:
              df_stamp.loc[:, dt_col] = list(df[dt_col].values)
          data_stamp = time_features(
              pd.to_datetime(df_stamp[dt_col].values), freq=freq
          )
          self.data_stamp_arr = data_stamp.transpose(1, 0)
  
file_path: BigDL/python/chronos/src/bigdl/chronos/data/utils/roll_dataset.py
imports: import numpy
  from torch.utils.data import Dataset
  import torch
  import pandas
  from bigdl.chronos.data.utils.utils import _check_cols_no_na, _to_list
  from bigdl.chronos.data.utils.time_feature import time_features, gen_time_enc_arr
label_desc: Use image node_id 1 to create a new RollDataset object from inherited base classes: Dataset with example: obj = RollDataset(df, dt_col, freq, lookback, horizon, feature_col, target_col, id_col, time_enc, label_len, is_predict)