def get_balanced_account(self):
        if not self.balanced_customer_href:
            customer = balanced.Customer(meta={
                'username': self.username,
                'participant_id': self.id,
            }).save()
            r = self.db.one("""
                UPDATE participants
                   SET balanced_customer_href=%s
                 WHERE id=%s
                   AND balanced_customer_href IS NULL
             RETURNING id
            """, (customer.href, self.id))
            if not r:
                return self.get_balanced_account()
        else:
            customer = balanced.Customer.fetch(self.balanced_customer_href)
        return customer
Cumulative product for each group
dataset/ETHPy150Open gratipay/gratipay.com/gratipay/models/participant.py/Participant.get_balanced_account--crossover with--dataset/ETHPy150Open pydata/pandas/pandas/core/groupby.py/GroupBy.cumprod