(data, period, granularity, piecewise_median_period_weeks)
return all_data
Processes result set when longterm is set to true

      data : list of floats
        the result set of anoms
      period : int
        the calculated or overridden period value
      granularity : string
        the calculated or overridden granularity
      piecewise_median_period_weeks : int
        used to determine days and observations per period
Processes result set when longterm is set to true
Processes result set when longterm is set to true
def _process_long_term_data(data, period, granularity, piecewise_median_period_weeks):
    """
    Processes result set when longterm is set to true

      data : list of floats
        the result set of anoms
      period : int
        the calculated or overridden period value
      granularity : string
        the calculated or overridden granularity
      piecewise_median_period_weeks : int
        used to determine days and observations per period
    """
    # Pre-allocate list with size equal to the number of piecewise_median_period_weeks chunks in x + any left over chunk
    # handle edge cases for daily and single column data period lengths
    num_obs_in_period = period * piecewise_median_period_weeks + \
        1 if granularity == 'day' else period * 7 * piecewise_median_period_weeks
    num_days_in_period = (7 * piecewise_median_period_weeks) + \
        1 if granularity == 'day' else (7 * piecewise_median_period_weeks)

    all_data = []
    # Subset x into piecewise_median_period_weeks chunks
    for i in range(1, data.size + 1, num_obs_in_period):
        start_date = data.index[i]
        # if there is at least 14 days left, subset it, otherwise subset last_date - 14 days
        end_date = start_date + datetime.timedelta(days=num_days_in_period)
        if end_date < data.index[-1]:
            all_data.append(
                data.loc[lambda x: (x.index >= start_date) & (x.index <= end_date)])
        else:
            all_data.append(
                data.loc[lambda x: x.index >= data.index[-1] - datetime.timedelta(days=num_days_in_period)])
    return all_data
def _process_long_term_data ( data , period , granularity , piecewise_median_period_weeks ) : # Pre-allocate list with size equal to the number of piecewise_median_period_weeks chunks in x + any left over chunk # handle edge cases for daily and single column data period lengths num_obs_in_period = period * piecewise_median_period_weeks + 1 if granularity == 'day' else period * 7 * piecewise_median_period_weeks num_days_in_period = ( 7 * piecewise_median_period_weeks ) + 1 if granularity == 'day' else ( 7 * piecewise_median_period_weeks ) all_data = [ ] # Subset x into piecewise_median_period_weeks chunks for i in range ( 1 , data . size + 1 , num_obs_in_period ) : start_date = data . index [ i ] # if there is at least 14 days left, subset it, otherwise subset last_date - 14 days end_date = start_date + datetime . timedelta ( days = num_days_in_period ) if end_date < data . index [ - 1 ] : all_data . append ( data . loc [ lambda x : ( x . index >= start_date ) & ( x . index <= end_date ) ] ) else : all_data . append ( data . loc [ lambda x : x . index >= data . index [ - 1 ] - datetime . timedelta ( days = num_days_in_period ) ] ) return all_data