def build(self, show_digits=2, add_totals=True):
        """Build the binning table.

        Parameters
        ----------
        show_digits : int, optional (default=2)
            The number of significant digits of the bin column.

        add_totals : bool (default=True)
            Whether to add a last row with totals.

        Returns
        -------
        binning_table : pandas.DataFrame
        """
        _check_build_parameters(show_digits, add_totals)

        t_n_records = np.nansum(self.n_records)
        t_sum = np.nansum(self.sums)
        p_records = self.n_records / t_n_records

        mask = (self.n_records > 0)
        self._mean = np.zeros(len(self.n_records))
        self._mean[mask] = self.sums[mask] / self.n_records[mask]

        # Compute HHI
        self._hhi = hhi(p_records)
        self._hhi_norm = hhi(p_records, normalized=True)

        bins = np.concatenate([[-np.inf], self.splits, [np.inf]])
        bin_str = bin_str_format(bins, show_digits)

        if isinstance(self.special_codes, dict):
            self._n_specials = len(self.special_codes)
            bin_str.extend(list(self.special_codes) + ["Missing"])
        else:
            self._n_specials = 1
            bin_str.extend(["Special", "Missing"])

        df = pd.DataFrame({
            "Bin": bin_str,
            "Count": self.n_records,
            "Count (%)": p_records,
            "Sum": self.sums,
            "Std": self.stds,
            "Min": self.min_target,
            "Max": self.max_target,
            "Zeros count": self.n_zeros,
            })

        n_coefs = self.coef.shape[1]

        n_bins_extra = self._n_specials + 1
        for i in range(n_coefs):
            if i == 0:
                extra_bins = list(self._mean[-n_bins_extra:])
            else:
                extra_bins = [0] * n_bins_extra

            df["c{}".format(i)] = list(self.coef[:, i]) + extra_bins

        if add_totals:
            t_min = np.nanmin(self.min_target[:-n_bins_extra])
            t_max = np.nanmax(self.max_target[:-n_bins_extra])
            t_n_zeros = self.n_zeros.sum()
            totals = ["", t_n_records, 1, t_sum, "", t_min, t_max, t_n_zeros]
            totals += ["-"] * n_coefs
            df.loc["Totals"] = totals

        self._is_built = True

        return df
Build the binning table.

        Parameters
        ----------
        show_digits : int, optional (default=2)
            The number of significant digits of the bin column.

        add_totals : bool (default=True)
            Whether to add a last row with totals.

        Returns
        -------
        binning_table : pandas.DataFrame
        
optbinning/binning/piecewise/binning_statistics.py