class_docstr: A collection of univariate time series, where each row is identified by an (``item_id``, ``timestamp``) pair.
  
  For example, a time series data frame could represent the daily sales of a collection of products, where each
  ``item_id`` corresponds to a product and ``timestamp`` corresponds to the day of the record.
  
  Parameters
  ----------
  data : pd.DataFrame, str, pathlib.Path or Iterable
      Time series data to construct a ``TimeSeriesDataFrame``. The class currently supports four input formats.
  
      1. Time series data in a pandas DataFrame format without multi-index. For example::
  
                 item_id  timestamp  target
              0        0 2019-01-01       0
              1        0 2019-01-02       1
              2        0 2019-01-03       2
              3        1 2019-01-01       3
              4        1 2019-01-02       4
              5        1 2019-01-03       5
              6        2 2019-01-01       6
              7        2 2019-01-02       7
              8        2 2019-01-03       8
  
      You can also use :meth:`~autogluon.timeseries.TimeSeriesDataFrame.from_data_frame` for loading data in such format.
  
      2. Path to a data file in CSV or Parquet format. The file must contain columns ``item_id`` and ``timestamp``, as well as columns with time series values. This is similar to Option 1 above (pandas DataFrame format without multi-index). Both remote (e.g., S3) and local paths are accepted. You can also use :meth:`~autogluon.timeseries.TimeSeriesDataFrame.from_path` for loading data in such format.
  
      3. Time series data in pandas DataFrame format with multi-index on ``item_id`` and ``timestamp``. For example::
  
                                  target
              item_id timestamp
              0       2019-01-01       0
                      2019-01-02       1
                      2019-01-03       2
              1       2019-01-01       3
                      2019-01-02       4
                      2019-01-03       5
              2       2019-01-01       6
                      2019-01-02       7
                      2019-01-03       8
  
      4. Time series data in Iterable format. For example::
  
              iterable_dataset = [
                  {"target": [0, 1, 2], "start": pd.Period("01-01-2019", freq='D')},
                  {"target": [3, 4, 5], "start": pd.Period("01-01-2019", freq='D')},
                  {"target": [6, 7, 8], "start": pd.Period("01-01-2019", freq='D')}
              ]
  
      You can also use :meth:`~autogluon.timeseries.TimeSeriesDataFrame.from_iterable_dataset` for loading data in such format.
  
  static_features : pd.DataFrame, str or pathlib.Path, optional
      An optional data frame describing the metadata of each individual time series that does not change with time.
      Can take real-valued or categorical values. For example, if ``TimeSeriesDataFrame`` contains sales of various
      products, static features may refer to time-independent features like color or brand.
  
      The index of the ``static_features`` index must contain a single entry for each item present in the respective
      ``TimeSeriesDataFrame``. For example, the following ``TimeSeriesDataFrame``::
  
                              target
          item_id timestamp
          A       2019-01-01       0
                  2019-01-02       1
                  2019-01-03       2
          B       2019-01-01       3
                  2019-01-02       4
                  2019-01-03       5
  
      is compatible with the following ``static_features``::
  
                   feat_1 feat_2
          item_id
          A           2.0    bar
          B           5.0    foo
  
      ``TimeSeriesDataFrame`` will ensure consistency of static features during serialization/deserialization, copy
      and slice operations.
  
      If ``static_features`` are provided during ``fit``, the ``TimeSeriesPredictor`` expects the same metadata to be
      available during prediction time.
  id_column : str, optional
      Name of the ``item_id`` column, if it's different from the default. This argument is only used when
      constructing a TimeSeriesDataFrame using format 1 (DataFrame without multi-index) or 2 (path to a file).
  timestamp_column : str, optional
      Name of the ``timestamp`` column, if it's different from the default. This argument is only used when
      constructing a TimeSeriesDataFrame using format 1 (DataFrame without multi-index) or 2 (path to a file).
  num_cpus : int, default = -1
      Number of CPU cores used to process the iterable dataset in parallel. Set to -1 to use all cores. This argument
      is only used when constructing a TimeSeriesDataFrame using format 4 (iterable dataset).
  
  Attributes
  ----------
  freq : str
      A pandas-compatible string describing the frequency of the time series. For example ``"D"`` for daily data,
      ``"H"`` for hourly data, etc. This attribute is determined automatically based on the timestamps. For the full
      list of possible values, see `pandas documentation <https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases>`_.
  num_items : int
      Number of items (time series) in the data set.
  item_ids : pd.Index
      List of unique time series IDs contained in the data set.
class_docstr_tok: ["A","collection","of","univariate","time","series",",","where","each","row","is","identified","by","an","(","``","item_id","``",",","``","timestamp","``",")","pair",".","For","example",",","a","time","series","data","frame","could","represent","the","daily","sales","of","a","collection","of","products",",","where","each","``","item_id","``","corresponds","to","a","product","and","``","timestamp","``","corresponds","to","the","day","of","the","record",".","Parameters","--","--","--","--","--","data",":","pd.DataFrame",",","str",",","pathlib.Path","or","Iterable","Time","series","data","to","construct","a","``","TimeSeriesDataFrame","``",".","The","class","currently","supports","four","input","formats",".","1",".","Time","series","data","in","a","pandas","DataFrame","format","without","multi-index",".","For","example",":",":","item_id","timestamp","target","0","0","2019-01-01","0","1","0","2019-01-02","1","2","0","2019-01-03","2","3","1","2019-01-01","3","4","1","2019-01-02","4","5","1","2019-01-03","5","6","2","2019-01-01","6","7","2","2019-01-02","7","8","2","2019-01-03","8","You","can","also","use",":","meth",":","`","~autogluon.timeseries.TimeSeriesDataFrame.from_data_frame","`","for","loading","data","in","such","format",".","2",".","Path","to","a","data","file","in","CSV","or","Parquet","format",".","The","file","must","contain","columns","``","item_id","``","and","``","timestamp","``",",","as","well","as","columns","with","time","series","values",".","This","is","similar","to","Option","1","above","(","pandas","DataFrame","format","without","multi-index",")",".","Both","remote","(","e.g.",",","S3",")","and","local","paths","are","accepted",".","You","can","also","use",":","meth",":","`","~autogluon.timeseries.TimeSeriesDataFrame.from_path","`","for","loading","data","in","such","format",".","3",".","Time","series","data","in","pandas","DataFrame","format","with","multi-index","on","``","item_id","``","and","``","timestamp","``",".","For","example",":",":","target","item_id","timestamp","0","2019-01-01","0","2019-01-02","1","2019-01-03","2","1","2019-01-01","3","2019-01-02","4","2019-01-03","5","2","2019-01-01","6","2019-01-02","7","2019-01-03","8","4",".","Time","series","data","in","Iterable","format",".","For","example",":",":","iterable_dataset","=","[","{","``","target","''",":","[","0",",","1",",","2","]",",","``","start","''",":","pd.Period","(","``","01-01-2019","''",",","freq='D","'",")","}",",","{","``","target","''",":","[","3",",","4",",","5","]",",","``","start","''",":","pd.Period","(","``","01-01-2019","''",",","freq='D","'",")","}",",","{","``","target","''",":","[","6",",","7",",","8","]",",","``","start","''",":","pd.Period","(","``","01-01-2019","''",",","freq='D","'",")","}","]","You","can","also","use",":","meth",":","`","~autogluon.timeseries.TimeSeriesDataFrame.from_iterable_dataset","`","for","loading","data","in","such","format",".","static_features",":","pd.DataFrame",",","str","or","pathlib.Path",",","optional","An","optional","data","frame","describing","the","metadata","of","each","individual","time","series","that","does","not","change","with","time",".","Can","take","real-valued","or","categorical","values",".","For","example",",","if","``","TimeSeriesDataFrame","``","contains","sales","of","various","products",",","static","features","may","refer","to","time-independent","features","like","color","or","brand",".","The","index","of","the","``","static_features","``","index","must","contain","a","single","entry","for","each","item","present","in","the","respective","``","TimeSeriesDataFrame","``",".","For","example",",","the","following","``","TimeSeriesDataFrame","``",":",":","target","item_id","timestamp","A","2019-01-01","0","2019-01-02","1","2019-01-03","2","B","2019-01-01","3","2019-01-02","4","2019-01-03","5","is","compatible","with","the","following","``","static_features","``",":",":","feat_1","feat_2","item_id","A","2.0","bar","B","5.0","foo","``","TimeSeriesDataFrame","``","will","ensure","consistency","of","static","features","during","serialization\/deserialization",",","copy","and","slice","operations",".","If","``","static_features","``","are","provided","during","``","fit","``",",","the","``","TimeSeriesPredictor","``","expects","the","same","metadata","to","be","available","during","prediction","time",".","id_column",":","str",",","optional","Name","of","the","``","item_id","``","column",",","if","it","'s","different","from","the","default",".","This","argument","is","only","used","when","constructing","a","TimeSeriesDataFrame","using","format","1","(","DataFrame","without","multi-index",")","or","2","(","path","to","a","file",")",".","timestamp_column",":","str",",","optional","Name","of","the","``","timestamp","``","column",",","if","it","'s","different","from","the","default",".","This","argument","is","only","used","when","constructing","a","TimeSeriesDataFrame","using","format","1","(","DataFrame","without","multi-index",")","or","2","(","path","to","a","file",")",".","num_cpus",":","int",",","default","=","-1","Number","of","CPU","cores","used","to","process","the","iterable","dataset","in","parallel",".","Set","to","-1","to","use","all","cores",".","This","argument","is","only","used","when","constructing","a","TimeSeriesDataFrame","using","format","4","(","iterable","dataset",")",".","Attributes","--","--","--","--","--","freq",":","str","A","pandas-compatible","string","describing","the","frequency","of","the","time","series",".","For","example","``","``","D","''","``","for","daily","data",",","``","``","H","''","``","for","hourly","data",",","etc",".","This","attribute","is","determined","automatically","based","on","the","timestamps",".","For","the","full","list","of","possible","values",",","see","`","pandas","documentation","<","https",":","\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/timeseries.html","#","offset-aliases",">","`","_",".","num_items",":","int","Number","of","items","(","time","series",")","in","the","data","set",".","item_ids",":","pd.Index","List","of","unique","time","series","IDs","contained","in","the","data","set","."]
docstr: Select a subsequence from each time series between start (inclusive) and end (exclusive) indices.
  
  This operation is equivalent to selecting a slice ``[start_index : end_index]`` from each time series, and then
  combining these slices into a new ``TimeSeriesDataFrame``. See examples below.
  
  Returns a copy of the original data. This is useful for constructing holdout sets for validation.
  
  Parameters
  ----------
  start_index : int or None
      Start index (inclusive) of the slice for each time series.
      Negative values are counted from the end of each time series.
      When set to None, the slice starts from the beginning of each time series.
  end_index : int or None
      End index (exclusive) of the slice for each time series.
      Negative values are counted from the end of each time series.
      When set to None, the slice includes the end of each time series.
  
  Returns
  -------
  ts_df : TimeSeriesDataFrame
      A new time series dataframe containing entries of the original time series between start and end indices.
  
  Examples
  --------
  >>> ts_df
                      target
  item_id timestamp
  0       2019-01-01       0
          2019-01-02       1
          2019-01-03       2
  1       2019-01-02       3
          2019-01-03       4
          2019-01-04       5
  2       2019-01-03       6
          2019-01-04       7
          2019-01-05       8
  
  Select the first entry of each time series
  
  >>> df.slice_by_timestep(0, 1)
                      target
  item_id timestamp
  0       2019-01-01       0
  1       2019-01-02       3
  2       2019-01-03       6
  
  Select the last 2 entries of each time series
  
  >>> df.slice_by_timestep(-2, None)
                      target
  item_id timestamp
  0       2019-01-02       1
          2019-01-03       2
  1       2019-01-03       4
          2019-01-04       5
  2       2019-01-04       7
          2019-01-05       8
  
  Select all except the last entry of each time series
  
  >>> df.slice_by_timestep(None, -1)
                      target
  item_id timestamp
  0       2019-01-01       0
          2019-01-02       1
  1       2019-01-02       3
          2019-01-03       4
  2       2019-01-03       6
          2019-01-04       7
  
  Copy the entire dataframe
  
  >>> df.slice_by_timestep(None, None)
                      target
  item_id timestamp
  0       2019-01-01       0
          2019-01-02       1
          2019-01-03       2
  1       2019-01-02       3
          2019-01-03       4
          2019-01-04       5
  2       2019-01-03       6
          2019-01-04       7
          2019-01-05       8
docstr_tok: ["Select","a","subsequence","from","each","time","series","between","start","(","inclusive",")","and","end","(","exclusive",")","indices",".","This","operation","is","equivalent","to","selecting","a","slice","``","[","start_index",":","end_index","]","``","from","each","time","series",",","and","then","combining","these","slices","into","a","new","``","TimeSeriesDataFrame","``",".","See","examples","below",".","Returns","a","copy","of","the","original","data",".","This","is","useful","for","constructing","holdout","sets","for","validation",".","Parameters","--","--","--","--","--","start_index",":","int","or","None","Start","index","(","inclusive",")","of","the","slice","for","each","time","series",".","Negative","values","are","counted","from","the","end","of","each","time","series",".","When","set","to","None",",","the","slice","starts","from","the","beginning","of","each","time","series",".","end_index",":","int","or","None","End","index","(","exclusive",")","of","the","slice","for","each","time","series",".","Negative","values","are","counted","from","the","end","of","each","time","series",".","When","set","to","None",",","the","slice","includes","the","end","of","each","time","series",".","Returns","--","--","--","-","ts_df",":","TimeSeriesDataFrame","A","new","time","series","dataframe","containing","entries","of","the","original","time","series","between","start","and","end","indices",".","Examples","--","--","--","--",">",">",">","ts_df","target","item_id","timestamp","0","2019-01-01","0","2019-01-02","1","2019-01-03","2","1","2019-01-02","3","2019-01-03","4","2019-01-04","5","2","2019-01-03","6","2019-01-04","7","2019-01-05","8","Select","the","first","entry","of","each","time","series",">",">",">","df.slice_by_timestep","(","0",",","1",")","target","item_id","timestamp","0","2019-01-01","0","1","2019-01-02","3","2","2019-01-03","6","Select","the","last","2","entries","of","each","time","series",">",">",">","df.slice_by_timestep","(","-2",",","None",")","target","item_id","timestamp","0","2019-01-02","1","2019-01-03","2","1","2019-01-03","4","2019-01-04","5","2","2019-01-04","7","2019-01-05","8","Select","all","except","the","last","entry","of","each","time","series",">",">",">","df.slice_by_timestep","(","None",",","-1",")","target","item_id","timestamp","0","2019-01-01","0","2019-01-02","1","1","2019-01-02","3","2019-01-03","4","2","2019-01-03","6","2019-01-04","7","Copy","the","entire","dataframe",">",">",">","df.slice_by_timestep","(","None",",","None",")","target","item_id","timestamp","0","2019-01-01","0","2019-01-02","1","2019-01-03","2","1","2019-01-02","3","2019-01-03","4","2019-01-04","5","2","2019-01-03","6","2019-01-04","7","2019-01-05","8"]
code: def slice_by_timestep(
      self,
      start_index: Optional[int] = None,
      end_index: Optional[int] = None,
  ) -> TimeSeriesDataFrame:
      """Select a subsequence from each time series between start (inclusive) and end (exclusive) indices.
  
      This operation is equivalent to selecting a slice ``[start_index : end_index]`` from each time series, and then
      combining these slices into a new ``TimeSeriesDataFrame``. See examples below.
  
      Returns a copy of the original data. This is useful for constructing holdout sets for validation.
  
      Parameters
      ----------
      start_index : int or None
          Start index (inclusive) of the slice for each time series.
          Negative values are counted from the end of each time series.
          When set to None, the slice starts from the beginning of each time series.
      end_index : int or None
          End index (exclusive) of the slice for each time series.
          Negative values are counted from the end of each time series.
          When set to None, the slice includes the end of each time series.
  
      Returns
      -------
      ts_df : TimeSeriesDataFrame
          A new time series dataframe containing entries of the original time series between start and end indices.
  
      Examples
      --------
      >>> ts_df
                          target
      item_id timestamp
      0       2019-01-01       0
              2019-01-02       1
              2019-01-03       2
      1       2019-01-02       3
              2019-01-03       4
              2019-01-04       5
      2       2019-01-03       6
              2019-01-04       7
              2019-01-05       8
  
      Select the first entry of each time series
  
      >>> df.slice_by_timestep(0, 1)
                          target
      item_id timestamp
      0       2019-01-01       0
      1       2019-01-02       3
      2       2019-01-03       6
  
      Select the last 2 entries of each time series
  
      >>> df.slice_by_timestep(-2, None)
                          target
      item_id timestamp
      0       2019-01-02       1
              2019-01-03       2
      1       2019-01-03       4
              2019-01-04       5
      2       2019-01-04       7
              2019-01-05       8
  
      Select all except the last entry of each time series
  
      >>> df.slice_by_timestep(None, -1)
                          target
      item_id timestamp
      0       2019-01-01       0
              2019-01-02       1
      1       2019-01-02       3
              2019-01-03       4
      2       2019-01-03       6
              2019-01-04       7
  
      Copy the entire dataframe
  
      >>> df.slice_by_timestep(None, None)
                          target
      item_id timestamp
      0       2019-01-01       0
              2019-01-02       1
              2019-01-03       2
      1       2019-01-02       3
              2019-01-03       4
              2019-01-04       5
      2       2019-01-03       6
              2019-01-04       7
              2019-01-05       8
  
      """
      if start_index is not None and not isinstance(start_index, int):
          raise ValueError(
              f"start_index must be of type int or None (got {type(start_index)})"
          )
      if end_index is not None and not isinstance(end_index, int):
          raise ValueError(
              f"end_index must be of type int or None (got {type(end_index)})"
          )
  
      time_step_slice = slice(start_index, end_index)
      result = self.groupby(
          level=ITEMID, sort=False, as_index=False
      ).nth(time_step_slice)
      result.static_features = self.static_features
      result._cached_freq = self._cached_freq
      return result
  
imports: from __future__ import annotations
  import copy
  import itertools
  import logging
  import reprlib
  from collections.abc import Iterable
  from itertools import islice
  from pathlib import Path
  from typing import Any, List, Optional, Tuple, Type, Union
  import pandas
  from joblib.parallel import Parallel, delayed
  from pandas.core.internals import ArrayManager, BlockManager
  from autogluon.common.loaders import load_pd
label_desc: Use image node_id 22 for calling the TimeSeriesDataFrame obj's underlying member method code with example usage: obj.slice_by_timestep(start_index, end_index) and returns: result