def rare_category_replacement(data, column, replace_col, cutoff=3):
    """
    Replace any categorical values that occur less than cutoff times 
    in data[column] with data[replace_col]
    
    Args:
        data - a pandas DataFrame
        column - the name of the column that is being thresholded
        replace_col - the name of the column that is used for replacement values
        cutoff - the cutoff threshold for replacement
    
    Returns:
        a DataFrame that has any values in data[column] that occur less than
        cutoff time replaced with data[replace_col]
    """
    counts = {}
    data[column] = data[column].astype('S100')
    data[replace_col] = data[replace_col].astype('S100')
    for idx in data.index:
        counts[data[column][idx]] = counts.get(data[column][idx], 0) + 1
    
    for idx in data.index:
        if counts[data[column][idx]] < cutoff:
            data[column][idx] = data[replace_col][idx]
    return data