def create_stat()

in perfrunbook/utilities/measure_aggregated_pmu_stats.py [0:0]


    def create_stat(self, df):
        """
        Returns series of the counter ratios from the individual counter measurements for
        plotting or statistical manipulation
        """
        if self.numerator and not self.denominator:
            return (df[df["counter"] == self.numerator.get_canonical_name()]["count"].reset_index(drop=True)) * self.scale

        # Find the groups our counters belong to, the intersection of the groups are the measurements we
        # can use to calculate the ratio accurately.
        series = []
        group_id = (
            set(df[df["counter"] == self.numerator.get_canonical_name()]["group"].unique())
            & set(df[df["counter"] == self.denominator.get_canonical_name()]["group"].unique())
        )

        for group in group_id:
            ctr1_df = df[(df["counter"] == self.numerator.get_canonical_name()) & (df["group"] == group)]
            ctr2_df = df[(df["counter"] == self.denominator.get_canonical_name()) & (df["group"] == group)]

            idx = df[(df["group"] == group)].index

            s = self._compute_stat(ctr1_df, ctr2_df, idx)
            if s is not None and s.size:
                series.append(s)

        if len(series):
            return pd.concat(series)
        else:
            return None