def category_grouping(data):
    """
    Each of the features "TrafficType", "OperatingSystems", and "Browser"
    contain categorical values with less than 1% (123) overall datapoints.
    Since these "categorical outliers" could potentially skew a clustering
    algorithm, we will combine each value with ten or fewer datapoints into
    a single "Other" value.

    Parameters:
    data: The dataset in question.

    Returns:
    data: The transformed dataset.
    """
    data['TrafficType'] = data['TrafficType'].apply(lambda x: 'Other' if x in
                                                    ['7', '9', '12', '14',
                                                     '15', '16', '17', '18',
                                                     '19']
                                                    else x)
    data['OperatingSystems'] = data['OperatingSystems'].apply(lambda x: 'Other'
                                                              if x in
                                                              ['4', '5', '6',
                                                               '7', '8']
                                                              else x)
    data['Browser'] = data['Browser'].apply(lambda x: 'Other' if x in
                                            ['3', '7', '9', '11', '12', '13']
                                            else x)
    data['VisitorType'] = data['VisitorType'].apply(lambda x: x if
                                                    x == 'Returning_Visitor'
                                                    else 'New_or_Other')
    return data