I asked this question for R a few months back and got a great answer that I used often. Now I\'m trying to transition to Python but I was dreading attempting rewriting this