Why does pandas code often feel ugly and clunky compared to the equivalent SQL? Is there no better way to do this?