code: def _group_range(records, method):
      
  
      start_date = records[0].datetime
      end_date = records[-1].datetime
      _fun = DATE_GROUPERS[method]
  
      d = start_date
  
      # Day and week use timedelta
      if method not in ["month", "year"]:
          def increment(i):
              return i + timedelta(**{method + 's': 1})
  
      elif method == "month":
          def increment(i):
              year, month = divmod(i.month + 1, 12)
              if month == 0:
                  month = 12
                  year = year - 1
              return d.replace(year=d.year + year, month=month)
  
      elif method == "year":
          def increment(i):
              return d.replace(year=d.year + 1)
  
      while _fun(d) <= _fun(end_date):
          yield d
          d = increment(d)
docs: Yield the range of all dates between the extrema of
      a list of records, separated by a given time delta.