def _ros_group_rank(df, dl_idx, censorship):
    """
    Ranks each result within the groups defined by the record's
    detection limit index and censorship.
    Parameters
    ----------
    df : pandas.DataFrame
    dl_idx : str
        Name of the column in the dataframe the index of the result's
        corresponding detection limit in the `cohn` dataframe.
    censorship : str
        Name of the column in the dataframe that indicates that a
        result is left-censored. (i.e., True -> censored,
        False -> uncensored)
    Returns
    -------
    ranks : numpy.array
        Array of ranks for the dataset.
    """
    ranks = df.assign(rank=1).groupby(by=[dl_idx, censorship])['rank'
        ].transform(lambda g: g.cumsum())
    return ranks
