class_docstr: Please read the `tutorial <tutorials/TimeSeries>` before reading this API doc.
  This class is a time-indexed ``pd.Series`` which represents a univariate
  time series. For the most part, it supports all the same features as
  ``pd.Series``, with the following key differences to iteration and indexing:
  
  1.  Iterating over a `UnivariateTimeSeries` is implemented as
  
      .. code-block:: python
  
          for timestamp, value in univariate:
              # do stuff...
  
      where ``timestamp`` is a Unix timestamp, and ``value`` is the
      corresponding time series value.
  2.  Integer index: ``u[i]`` yields the tuple ``(u.time_stamps[i], u.values[i])``
  3.  Slice index: ``u[i:j:k]`` yields a new
      ``UnivariateTimeSeries(u.time_stamps[i:j:k], u.values[i:j:k])``
  
  The class also supports the following additional features:
  
  1.  ``univariate.time_stamps`` returns the list of Unix timestamps, and
      ``univariate.values`` returns the list of the time series values. You
      may access the ``pd.DatetimeIndex`` directly with ``univariate.index``
      (or its ``np.ndarray`` representation with ``univariate.np_time_stamps``),
      and the ``np.ndarray`` of values with ``univariate.np_values``.
  2.  ``univariate.concat(other)`` will concatenate the UnivariateTimeSeries
      ``other`` to the right end of ``univariate``.
  3.  ``left, right = univariate.bisect(t)`` will split the univariate at the
      given timestamp ``t``.
  4.  ``window = univariate.window(t0, tf)`` will return the subset of the time
      series occurring between timestamps ``t0`` (inclusive) and ``tf``
      (non-inclusive)
  5.  ``series = univariate.to_pd()`` will convert the `UnivariateTimeSeries`
      into a regular ``pd.Series`` (for compatibility).
  6.  ``univariate = UnivariateTimeSeries.from_pd(series)`` uses a time-indexed
      ``pd.Series`` to create a `UnivariateTimeSeries` object directly.
  
  .. document special functions
  .. automethod:: __getitem__
  .. automethod:: __iter__
class_docstr_tok: ["Please","read","the","`","tutorial","<","tutorials\/TimeSeries",">","`","before","reading","this","API","doc",".","This","class","is","a","time-indexed","``","pd.Series","``","which","represents","a","univariate","time","series",".","For","the","most","part",",","it","supports","all","the","same","features","as","``","pd.Series","``",",","with","the","following","key","differences","to","iteration","and","indexing",":","1",".","Iterating","over","a","`","UnivariateTimeSeries","`","is","implemented","as","..","code-block",":",":","python","for","timestamp",",","value","in","univariate",":","#","do","stuff","...","where","``","timestamp","``","is","a","Unix","timestamp",",","and","``","value","``","is","the","corresponding","time","series","value",".","2",".","Integer","index",":","``","u","[","i","]","``","yields","the","tuple","``","(","u.time_stamps","[","i","]",",","u.values","[","i","]",")","``","3",".","Slice","index",":","``","u","[","i",":","j",":","k","]","``","yields","a","new","``","UnivariateTimeSeries","(","u.time_stamps","[","i",":","j",":","k","]",",","u.values","[","i",":","j",":","k","]",")","``","The","class","also","supports","the","following","additional","features",":","1",".","``","univariate.time_stamps","``","returns","the","list","of","Unix","timestamps",",","and","``","univariate.values","``","returns","the","list","of","the","time","series","values",".","You","may","access","the","``","pd.DatetimeIndex","``","directly","with","``","univariate.index","``","(","or","its","``","np.ndarray","``","representation","with","``","univariate.np_time_stamps","``",")",",","and","the","``","np.ndarray","``","of","values","with","``","univariate.np_values","``",".","2",".","``","univariate.concat","(","other",")","``","will","concatenate","the","UnivariateTimeSeries","``","other","``","to","the","right","end","of","``","univariate","``",".","3",".","``","left",",","right","=","univariate.bisect","(","t",")","``","will","split","the","univariate","at","the","given","timestamp","``","t","``",".","4",".","``","window","=","univariate.window","(","t0",",","tf",")","``","will","return","the","subset","of","the","time","series","occurring","between","timestamps","``","t0","``","(","inclusive",")","and","``","tf","``","(","non-inclusive",")","5",".","``","series","=","univariate.to_pd","(",")","``","will","convert","the","`","UnivariateTimeSeries","`","into","a","regular","``","pd.Series","``","(","for","compatibility",")",".","6",".","``","univariate","=","UnivariateTimeSeries.from_pd","(","series",")","``","uses","a","time-indexed","``","pd.Series","``","to","create","a","`","UnivariateTimeSeries","`","object","directly",".","..","document","special","functions","..","automethod",":",":","__getitem__","..","automethod",":",":","__iter__"]
docstr: :param i: integer index or slice
  
  :rtype: Union[Tuple[float, float], UnivariateTimeSeries]
  :return: ``(self.time_stamps[i], self.values[i])`` if ``i`` is
      an integer. ``UnivariateTimeSeries(self.time_series[i], self.values[i])``
      if ``i`` is a slice.
code: def __getitem__(self, i: Union[int, slice]):
      """
      :param i: integer index or slice
  
      :rtype: Union[Tuple[float, float], UnivariateTimeSeries]
      :return: ``(self.time_stamps[i], self.values[i])`` if ``i`` is
          an integer. ``UnivariateTimeSeries(self.time_series[i], self.values[i])``
          if ``i`` is a slice.
      """
      if isinstance(i, int):
          return self.np_time_stamps[i].item(), self.np_values[i].item()
      elif isinstance(i, slice):
          return UnivariateTimeSeries.from_pd(self.iloc[i])
      else:
          raise KeyError(
              f"Indexing a `UnivariateTimeSeries` with key {i} of "
              f"type {type(i).__name__} is not supported. Try "
              f"using loc[] or iloc[] for more complicated "
              f"indexing."
          )
  
imports: from bisect import bisect_left, bisect_right
  import itertools
  import logging
  from typing import Any, Callable, Dict, Iterable, Mapping, Sequence, Tuple, Union
  import warnings
  import numpy
  import pandas
  from merlion.utils.misc import ValIterOrderedDict
  from merlion.utils.resample import AggregationPolicy, AlignPolicy, MissingValuePolicy, get_date_offset, infer_granularity, reindex_df, to_pd_datetime, to_timestamp, to_offset
label_desc: Use image node_id 10 for calling the UnivariateTimeSeries obj's underlying member method code with example usage: obj.__getitem__(i) and returns: self,  self, UnivariateTimeSeries