Python Pandas Group By Row Based Values Based On Condition Stack

Python Pandas Group By Row Based Values Based On Condition Stack