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 time_stamps: a sequence of Unix timestamps. You may specify
      ``None`` if you only have ``values`` with no specific time stamps.
  :param values: a sequence of univariate values, where ``values[i]``
      occurs at time ``time_stamps[i]``
  :param name: the name of the univariate time series
  :param freq: if ``time_stamps`` is not provided, the univariate is
      assumed to be sampled at frequency ``freq``. ``freq`` may be a
      string (e.g. ``"1h"``), timedelta, or ``int``/``float`` (in units
      of seconds).
code: def __init__(
      self,
      time_stamps: Union[None, Sequence[Union[int, float]]],
      values: Sequence[float],
      name: str = None,
      freq="1h",
  ):
      """
      :param time_stamps: a sequence of Unix timestamps. You may specify
          ``None`` if you only have ``values`` with no specific time stamps.
      :param values: a sequence of univariate values, where ``values[i]``
          occurs at time ``time_stamps[i]``
      :param name: the name of the univariate time series
      :param freq: if ``time_stamps`` is not provided, the univariate is
          assumed to be sampled at frequency ``freq``. ``freq`` may be a
          string (e.g. ``"1h"``), timedelta, or ``int``/``float`` (in units
          of seconds).
      """
      is_pd = isinstance(values, pd.Series)
      if name is None and is_pd:
          name = values.name
      if is_pd and isinstance(values.index, pd.DatetimeIndex):
          super().__init__(values, name=name)
      elif is_pd and values.index.dtype == "O":
          super().__init__(
              values.values,
              name=name,
              index=pd.to_datetime(values.index),
          )
      else:
          if time_stamps is None:
              freq = to_offset(freq)
              if is_pd and values.index.dtype in ("int64", "float64"):
                  index = pd.to_datetime(0) + freq * values.index
              else:
                  index = pd.date_range(
                      start=0, periods=len(values), freq=freq
                  )
          else:
              index = to_pd_datetime(time_stamps)
          super().__init__(
              np.asarray(values), index=index, name=name, dtype=float
          )
          if len(self) >= 3 and self.index.freq is None:
              self.index.freq = pd.infer_freq(self.index)
          self.index.name = _time_col_name
  
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 1 to create a new UnivariateTimeSeries object from inherited base classes: pd with example: obj = UnivariateTimeSeries(time_stamps, values, name, freq)