def get_mapping(series):
    """
    Map a series of n elements to 0, ..., n.

    Parameters
    ----------
    series : Pandas series (e.g. user-ids)

    Returns
    -------
    mapping : Dict[]
    """
    mapping = {}
    i = 0
    for element in series:
        if element not in mapping:
            mapping[element] = i
            i += 1

    return mapping