class_docstr: Dataset with Data(H)andler
  
  User should try to put the data preprocessing functions into handler.
  Only following data processing functions should be placed in Dataset:
  
  - The processing is related to specific model.
  
  - The processing is related to data split.
class_docstr_tok: ["Dataset","with","Data","(","H",")","andler","User","should","try","to","put","the","data","preprocessing","functions","into","handler",".","Only","following","data","processing","functions","should","be","placed","in","Dataset",":","-","The","processing","is","related","to","specific","model",".","-","The","processing","is","related","to","data","split","."]
docstr: Prepare the data for learning and inference.
  
  Parameters
  ----------
  segments : Union[List[Text], Tuple[Text], Text, slice]
      Describe the scope of the data to be prepared
      Here are some examples:
  
      - 'train'
  
      - ['train', 'valid']
  
  col_set : str
      The col_set will be passed to self.handler when fetching data.
      TODO: make it automatic:
  
      - select DK_I for test data
      - select DK_L for training data.
  data_key : str
      The data to fetch:  DK_*
      Default is DK_I, which indicate fetching data for **inference**.
  
  kwargs :
      The parameters that kwargs may contain:
          flt_col : str
              It only exists in TSDatasetH, can be used to add a column of data(True or False) to filter data.
              This parameter is only supported when it is an instance of TSDatasetH.
  
  Returns
  -------
  Union[List[pd.DataFrame], pd.DataFrame]:
  
  Raises
  ------
  NotImplementedError:
docstr_tok: ["Prepare","the","data","for","learning","and","inference",".","Parameters","--","--","--","--","--","segments",":","Union","[","List","[","Text","]",",","Tuple","[","Text","]",",","Text",",","slice","]","Describe","the","scope","of","the","data","to","be","prepared","Here","are","some","examples",":","-","'train'","-","[","'train","'",",","'valid","'","]","col_set",":","str","The","col_set","will","be","passed","to","self.handler","when","fetching","data",".","TODO",":","make","it","automatic",":","-","select","DK_I","for","test","data","-","select","DK_L","for","training","data",".","data_key",":","str","The","data","to","fetch",":","DK_","*","Default","is","DK_I",",","which","indicate","fetching","data","for","*","*","inference","*","*",".","kwargs",":","The","parameters","that","kwargs","may","contain",":","flt_col",":","str","It","only","exists","in","TSDatasetH",",","can","be","used","to","add","a","column","of","data","(","True","or","False",")","to","filter","data",".","This","parameter","is","only","supported","when","it","is","an","instance","of","TSDatasetH",".","Returns","--","--","--","-","Union","[","List","[","pd.DataFrame","]",",","pd.DataFrame","]",":","Raises","--","--","--","NotImplementedError",":"]
code: def prepare(
      self,
      segments: Union[List[Text], Tuple[Text], Text, slice, pd.Index],
      col_set=DataHandler.CS_ALL,
      data_key=DataHandlerLP.DK_I,
      **kwargs,
  ) -> Union[List[pd.DataFrame], pd.DataFrame]:
      """
      Prepare the data for learning and inference.
  
      Parameters
      ----------
      segments : Union[List[Text], Tuple[Text], Text, slice]
          Describe the scope of the data to be prepared
          Here are some examples:
  
          - 'train'
  
          - ['train', 'valid']
  
      col_set : str
          The col_set will be passed to self.handler when fetching data.
          TODO: make it automatic:
  
          - select DK_I for test data
          - select DK_L for training data.
      data_key : str
          The data to fetch:  DK_*
          Default is DK_I, which indicate fetching data for **inference**.
  
      kwargs :
          The parameters that kwargs may contain:
              flt_col : str
                  It only exists in TSDatasetH, can be used to add a column of data(True or False) to filter data.
                  This parameter is only supported when it is an instance of TSDatasetH.
  
      Returns
      -------
      Union[List[pd.DataFrame], pd.DataFrame]:
  
      Raises
      ------
      NotImplementedError:
      """
      logger = get_module_logger("DatasetH")
      seg_kwargs = {"col_set": col_set}
      seg_kwargs.update(kwargs)
      if "data_key" in getfullargspec(self.handler.fetch).args:
          seg_kwargs["data_key"] = data_key
      else:
          logger.info(f"data_key[{data_key}] is ignored.")
  
      # Conflictions may happen here
      # - The fetched data and the segment key may both be string
      # To resolve the confliction
      # - The segment name will have higher priorities
  
      # 1) Use it as segment name first
      if isinstance(segments, str) and segments in self.segments:
          return self._prepare_seg(
              self.segments[segments], **seg_kwargs
          )
  
      if isinstance(segments, (list, tuple)) and all(
          seg in self.segments for seg in segments
      ):
          return [
              self._prepare_seg(self.segments[seg], **seg_kwargs)
              for seg in segments
          ]
  
      # 2) Use pass it directly to prepare a single seg
      return self._prepare_seg(segments, **seg_kwargs)
  
imports: from ...utils.serial import Serializable
  from typing import Callable, Union, List, Tuple, Dict, Text, Optional
  from ...utils import init_instance_by_config, np_ffill, time_to_slc_point
  from ...log import get_module_logger
  from .handler import DataHandler, DataHandlerLP
  from copy import copy, deepcopy
  from inspect import getfullargspec
  import pandas
  import numpy
  import bisect
  from ...utils import lazy_sort_index
  from .utils import get_level_index
label_desc: Use image node_id 6 for calling the DatasetH obj's underlying member method code with example usage: obj.prepare(segments, col_set, data_key) and returns: self, self, unknown