Transform messy transactions with pandas | Boston Consulting Group SQL Question