def categorical_encoding(item, categories):
    """
    Numerical encoding items for specified categories.
    If there are no appropriate category, returns -1.

    :param object item: item to encode.
    :param list categories: categories to encode by.
    :return: digit.
    :rtype: int
    """
    for num, cat in enumerate(categories):
        if item == cat:
            return num
    else:
        return -1