def _add_poobah(poobah, extended=True):
    """ used by beta_MDS_plot to categorize poobah failure ranges for colormap.
    - Default returns 7 groups (0-30%). But 5 groups (0-20%) also an option with 'extended=False'.
    - Returns: a df with sample names in index and failure % in a column. """
    #if poobah.isna().sum().sum() > 0:
    #    LOGGER.warning("Your poobah_values.pkl file contains missing values; color coding may be inaccurate.")
    # this happens normally with qualityMask True
    percent_failures = round(100*( poobah[poobah > 0.05].count() / poobah.count() ),1)
    percent_failures = percent_failures.rename('probe_failure_(%)')
    # Series.where will replace the stuff that is False, so you have to negate it.
    percent_failures_hues = percent_failures.where(~percent_failures.between(0,5), 0)
    percent_failures_hues.where(~percent_failures_hues.between(5,10), 1, inplace=True)
    percent_failures_hues.where(~percent_failures_hues.between(10,15), 2, inplace=True)
    percent_failures_hues.where(~percent_failures_hues.between(15,20), 3, inplace=True)
    if extended:
        percent_failures_hues.where(~percent_failures_hues.between(20,25), 4, inplace=True)
        percent_failures_hues.where(~percent_failures_hues.between(25,30), 5, inplace=True)
        percent_failures_hues.where(~(percent_failures_hues > 30), 6, inplace=True)
        percent_failures_hues = percent_failures_hues.astype(int)
        percent_failures_hues = percent_failures_hues.replace({0:'0 to 5', 1:'5 to 10', 2:'10 to 15', 3:'15 to 20', 4:'20 to 25', 5:'25 to 30', 6:'>30'})
        legend_order = ['0 to 5','5 to 10','10 to 15','15 to 20','20 to 25','25 to 30','>30']
    else:
        percent_failures_hues.where(~(percent_failures_hues > 20), 4, inplace=True)
        percent_failures_hues = percent_failures_hues.astype(int)
        percent_failures_hues = percent_failures_hues.replace({0:'0 to 5', 1:'5 to 10', 2:'10 to 15', 3:'15 to 20', 4:'>20'})
        legend_order = ['0 to 5','5 to 10','10 to 15','15 to 20','>20']
    return percent_failures_hues, legend_order