def _one_thresh()

in src/mozanalysis/bayesian_stats/survival_func.py [0:0]


def _one_thresh(threshold, df, col_label, ref_branch_label):
    """Run stats on the fraction of clients above ``threshold``."""
    if df[col_label].isnull().any():
        raise ValueError(f"'df' contains null values for '{col_label}'")

    if "_tmp_threshold_val" in df.columns:
        raise ValueError(
            "Either you have an exceedingly poor taste in column names, "
            "or there is a bug in `_one_thresh`."
        )
    try:
        # Sorry for mutating the input inplace. I'll be sure to tidy up.
        df["_tmp_threshold_val"] = df[col_label] > threshold

        return mabsb.compare_branches(
            df, "_tmp_threshold_val", ref_branch_label=ref_branch_label
        )

    finally:
        df.drop("_tmp_threshold_val", axis="columns", inplace=True)