def truncate_stats(stat, threshold, name='Other'):
    """
    Combines all entries (name, count) with a count below the threshold and appends a new entry
    """
    a, b = [], []
    for s in stat:
        (a, b)[s[1] < threshold].append(s)
    c = 0
    for s in b:
        c += s[1]
    a.append([name, c])
    return a