from typing import Dict
from typing import Tuple


def cluster_expenses(d: Dict[str, float], total_expenses: float, min_quota: float = 0.025) \
                    -> Tuple[Dict[str, float], float]:
    """
        Combines all expenses that account for less than min_quota into one category 'other'.

    Args:
        d:              dict that contains the labels and the expenses
        total_expenses: total expenses of that period
        min_quota:      partition value

    Returns:
        Tuple: the new dictionary with new category other and the total expenses.

    """
    d['other'] = 0.
    for key in d.copy().keys():
        if d[key] < min_quota * total_expenses:
            d['other'] += d[key]
            del d[key]
    return d, total_expenses