docs: def groupby_freq(items, times, freq, wkst='SU'):
      """
      Group timeseries by frequency. The frequency must be a string in the
      following list: YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY or
      SECONDLY. The optional weekstart must be a string in the following list:
      MO, TU, WE, TH, FR, SA and SU.
  
      :param items: items in timeseries
      :param times: times corresponding to items
      :param freq: One of the ``dateutil.rrule`` frequency constants
      :type freq: str
      :param wkst: One of the ``dateutil.rrule`` weekday constants
      :type wkst: str
      :return: generator
      """
      timeseries = zip(times, items)  # timeseries map of items
      # create a key lambda to group timeseries by
      if freq.upper() == 'DAILY':
          def key(ts_): return ts_[0].day
      elif freq.upper() == 'WEEKLY':
          weekday = getattr(rrule, wkst.upper())  # weekday start
          # generator that searches times for weekday start
          days = (day for day in times if day.weekday() == weekday.weekday)
          day0 = days.next()  # first weekday start of all times
  
          def key(ts_): return (ts_[0] - day0).days // 7
      else:
          def key(ts_): return getattr(ts_[0], freq.lower()[:-2])
      for k, ts in itertools.groupby(timeseries, key):
          yield k, ts