def freq(series, value):
    """
    Takes a pandas series and a value and returns the fraction of the series that presents a certain value.
    """
    Ntotal = len(series)
    Nsel   = float(len(series.loc[series==value]))
    return Nsel/Ntotal