@grouping
def interactions_per_contact(records, direction=None):

    if direction is None:
        counter = Counter(r.correspondent_id for r in records)
    else:
        counter = Counter(r.correspondent_id for r in records if r.direction == direction)
    return summary_stats(counter.values())
Basic validation and fetch from an edit expense form
dataset/ETHPy150Open yvesalexandre/bandicoot/bandicoot/individual.py/interactions_per_contact--crossover with--dataset/ETHPy150Open radekstepan/FlaskBudget/presenters/expenses.py/__validate_expense_form