from typing import OrderedDict
from typing import Counter


def profile_nominal(pairs, **options):
    """Return stats for the nominal field

    Arguments:
    :param pairs: list with pairs (row, value)
    :return: dictionary with stats
    """
    result = OrderedDict()
    values = [r[1] for r in pairs]
    c = Counter(values)
    result['top'], result['freq'] = c.most_common(1)[0]
    categories = list(c)
    categories.sort()
    result['categories'] = categories
    result['categories_num'] = len(categories)

    return result