Returns series whose i-th entry is the number of examples in the top i

def count_series(y_true, y_score, countna=False):
    """
    Returns series whose i-th entry is the number of examples in the top i
    """
    y_true, y_score = to_float(y_true, y_score)
    top = _argsort(y_score)

    if not countna:
        a = (~np.isnan(y_true[top])).cumsum()
    else:
        a = range(1, len(y_true)+1)

    return pd.Series(a, index=range(1, len(a)+1))