Map categorical data to colors.

    Parameters
    ----------
    cats : pandas.Series or list
        Categorical data as a list or in a Series.

    colormap : list
        List of RGB triples. If not provided, the tableau20 colormap defined in
        this module will be used.

    Returns
    -------
    legend : pd.Series
        Series whose values are colors and whose index are the original
        categories that correspond to those colors.

def categories_to_colors(cats, colormap=None):
    """ 
    Map categorical data to colors.

    Parameters
    ----------
    cats : pandas.Series or list
        Categorical data as a list or in a Series.

    colormap : list
        List of RGB triples. If not provided, the tableau20 colormap defined in
        this module will be used.

    Returns
    -------
    legend : pd.Series
        Series whose values are colors and whose index are the original
        categories that correspond to those colors.

    """
    if colormap is None:
        colormap = tableau20
    if type(cats) != pd.Series:
        cats = pd.Series(cats)
    legend = pd.Series(dict(zip(set(cats), colormap)))
    # colors = pd.Series([legend[x] for x in cats.values], index=cats.index)
    # I've removed this output:
    # colors : pd.Series
    #     Series whose values are the colors for each category. If cats was a
    #     Series, then out will have the same index as cats.
    return(legend)