(data, all_anoms, granularity, only_last)
return all_anoms.loc[all_anoms.index >= x_subset_single_day.index[0]]
Returns the results from the last day or hour only

      data : pandas DataFrame
        input data set
      all_anoms : list of floats
        all of the anomalies returned by the algorithm
      granularity : string day | hr | min
        The supported granularity value
      only_last : string day | hr
        The subset of anomalies to be returned
Returns the results from the last day or hour only
Returns the results from the last day or hour only
def _get_only_last_results(data, all_anoms, granularity, only_last):
    """
    Returns the results from the last day or hour only

      data : pandas DataFrame
        input data set
      all_anoms : list of floats
        all of the anomalies returned by the algorithm
      granularity : string day | hr | min
        The supported granularity value
      only_last : string day | hr
        The subset of anomalies to be returned
    """
    start_date = data.index[-1] - datetime.timedelta(days=7)
    start_anoms = data.index[-1] - datetime.timedelta(days=1)

    if only_last == 'hr':
        # We need to change start_date and start_anoms for the hourly only_last option
        start_date = datetime.datetime.combine(
            (data.index[-1] - datetime.timedelta(days=2)).date(), datetime.time.min)
        start_anoms = data.index[-1] - datetime.timedelta(hours=1)

    # subset the last days worth of data
    x_subset_single_day = data.loc[data.index > start_anoms]
    # When plotting anoms for the last day only we only show the previous weeks data
    x_subset_week = data.loc[lambda df: (
        df.index <= start_anoms) & (df.index > start_date)]
    return all_anoms.loc[all_anoms.index >= x_subset_single_day.index[0]]
def _get_only_last_results ( data , all_anoms , granularity , only_last ) : start_date = data . index [ - 1 ] - datetime . timedelta ( days = 7 ) start_anoms = data . index [ - 1 ] - datetime . timedelta ( days = 1 ) if only_last == 'hr' : # We need to change start_date and start_anoms for the hourly only_last option start_date = datetime . datetime . combine ( ( data . index [ - 1 ] - datetime . timedelta ( days = 2 ) ) . date ( ) , datetime . time . min ) start_anoms = data . index [ - 1 ] - datetime . timedelta ( hours = 1 ) # subset the last days worth of data x_subset_single_day = data . loc [ data . index > start_anoms ] # When plotting anoms for the last day only we only show the previous weeks data x_subset_week = data . loc [ lambda df : ( df . index <= start_anoms ) & ( df . index > start_date ) ] return all_anoms . loc [ all_anoms . index >= x_subset_single_day . index [ 0 ] ]