Iterate through several time series in order, yielding (time, list)
        tuples where list is the values of each individual TimeSeries
        in the list at time t.
12234
def iter_merge(cls, timeseries_list):
        
        # using return without an argument is the way to say "the
        # iterator is empty" when there is nothing to iterate over
        # (the more you know...)
        if not timeseries_list:
            return

        # for ts in timeseries_list:
        #     if ts.is_floating():
        #         msg = "can't merge empty TimeSeries with no default value"
        #         raise KeyError(msg)

        # This function mostly wraps _iter_merge, the main point of
        # this is to deal with the case of tied times, where we only
        # want to yield the last list of values that occurs for any
        # group of tied times.
        index, previous_t, previous_state = -1, object(), object()
        for index, (t, state) in enumerate(cls._iter_merge(timeseries_list)):
            if index > 0 and t != previous_t:
                yield previous_t, previous_state
            previous_t, previous_state = t, state

        # only yield final thing if there was at least one element
        # yielded by _iter_merge
        if index > -1:
            yield previous_t, previous_state
1072120
def is_timeseries(nc, variable):
    '''
    
    '''

    # x, y, z, t(t)
    # X(t)
    dims = nc.variables[variable].dimensions
    cmatrix = coordinate_dimension_matrix(nc)
    time_variables = get_time_variables(nc)

    if len(dims) != 1:
        return False
    dim = dims[0]
    if dim not in time_variables:
        return False
    # No other coordinates can vary with time
    if 'x' in cmatrix:
        if len(cmatrix['x']) != 0:
            return False
    if 'y' in cmatrix:
        if len(cmatrix['y']) != 0:
            return False
    if 'z' in cmatrix:
        if len(cmatrix['z']) != 0:
            return False

    return True
417781
def GetCalendarDatesFieldValuesTuples(self):
    """"""
    result = []
    for date_tuple in self.GenerateCalendarDatesFieldValuesTuples():
      result.append(date_tuple)
    result.sort()  # helps with __eq__
    return result
646765
def trend(self, order=LINEAR):
        ''''''
        coefficients = self.trend_coefficients(order)
        x = self.timestamps
        trend_y = LazyImport.numpy().polyval(coefficients, x)
        return TimeSeries(zip(x, trend_y))
1301559
def predictions_iter(self):
        
        for fname in self.forecast_names:
            yield self.predictions.get(col_names=fname)
1129411
def f_rollup(items, times, freq):
    
    rollup = [np.sum(item for __, item in ts)
              for _, ts in groupby_freq(items, times, freq)]
    return np.array(rollup)
282988
def create_timeseries(self, **kwargs):
        
        ts = predix.admin.timeseries.TimeSeries(**kwargs)
        ts.create()

        client_id = self.get_client_id()
        if client_id:
            ts.grant_client(client_id)

        ts.add_to_manifest(self)
        return ts
14739
def dtypes(self):
        
        return Series(np.array(list(self._gather_dtypes().values()), dtype=np.bytes_),
                      self.keys())
1020735
def iteritems(cls):
        
        for key in dir(cls):
            val = getattr(cls, key)
            if isinstance(cls, val):
                yield (key, val)
865419
def iteritems(self, indices=None):
        ''
        if indices is None:
            indices = force_list(self.indices.keys())
        for x in self.itervalues(indices):
            yield x
498580
def time_serie_subsample(data, sampling):
    
    if len(data) <= sampling:
        return data
    t = [t[0] for t in data]
    v = [t[1] for t in data]
    sampling_length = int(round(len(data) / float(sampling)))
    t_subsampled = [t[s * sampling_length:(s + 1) * sampling_length][0] for s in range(0, sampling)]
    v_subsampled = [mean(v[s * sampling_length:(s + 1) * sampling_length]) for s in range(0, sampling)]
    return list(zip(t_subsampled, v_subsampled))
847215
def multi_iter(iterable, count=2):
    """"""
    # no need to special-case re-usable, container-like iterables
    if not isinstance(
            iterable,
            (
                    list, tuple, set,
                    FutureChainResults,
                    collections.Sequence, collections.Set, collections.Mapping, collections.MappingView
            )):
        iterable = SafeTee(iterable, n=count)
    return (iter(iterable) for _ in range(count))
266125
def samples(self):
        """"""
        names = self.series.dimensions
        for values in zip(*(getattr(self.series, name) for name in names)):
            yield dict(zip(names, values))
970981
def _load(self, metrix):
    
    if isinstance(metrix, TimeSeries):
      return metrix
    if isinstance(metrix, dict):
      return TimeSeries(metrix)
    return TimeSeries(utils.read_csv(metrix))
630773
def _process_items(cls, vals):
        ""
        if type(vals) is cls:
            return vals.data
        elif not isinstance(vals, (list, tuple)):
            vals = [vals]
        items = []
        counts = defaultdict(lambda: 1)
        cls._unpack_paths(vals, items, counts)
        items = cls._deduplicate_items(items)
        return items
916930
def iterintervals(self, n=2):
        
        # tee the original iterator into n identical iterators
        streams = tee(iter(self), n)

        # advance the "cursor" on each iterator by an increasing
        # offset, e.g. if n=3:
        #
        #                   [a, b, c, d, e, f, ..., w, x, y, z]
        #  first cursor -->  *
        # second cursor -->     *
        #  third cursor -->        *
        for stream_index, stream in enumerate(streams):
            for i in range(stream_index):
                next(stream)

        # now, zip the offset streams back together to yield tuples,
        # in the n=3 example it would yield:
        # (a, b, c), (b, c, d), ..., (w, x, y), (x, y, z)
        for intervals in zip(*streams):
            yield intervals
116576
def iterlists(self):
        """"""
        for key, values in dict.iteritems(self):
            yield key, list(values)