def process_day()

in docker/services/metrics_service.py [0:0]


    def process_day(self, df: pandas.DataFrame, algorithm: Algorithm):
        shutdown = []
        low_util = []
        good_util = []
        over_util = []

        df_, centroids = self.clustering_service.cluster(
            df=df,
            algorithm=algorithm)
        _LOG.debug(f'Clusters centroids: {centroids}')

        thresholds = algorithm.recommendation_settings.thresholds
        for index, centroid in enumerate(centroids):
            if not centroid:
                continue
            cluster: pd.DataFrame = df.loc[df['cluster'] == index]
            cluster.drop('cluster', axis=1, inplace=True)
            if centroid[0] < thresholds[0]:
                shutdown.append(cluster)
            elif thresholds[0] <= centroid[0] < \
                    thresholds[1]:
                low_util.append(cluster)
            elif thresholds[1] <= centroid[0] < \
                    thresholds[2]:
                good_util.append(cluster)
            else:
                over_util.append(cluster)

        shutdown = pd.concat(shutdown) if shutdown else None
        low_util = pd.concat(low_util) if low_util else None
        good_util = pd.concat(good_util) if good_util else None
        over_util = pd.concat(over_util) if over_util else None

        freq = f'{algorithm.recommendation_settings.record_step_minutes}Min'

        result = [self.get_time_ranges(cluster, freq=freq) for cluster in
                  (shutdown, low_util, good_util, over_util)]
        result.append(centroids)
        return result