Convert R function to Python

Hello all,
Trying to convert this R function into Python, anyone knows any tools that can I do this?
https://rstudio-pubs-static.s3.amazonaws.com/184497_dcd6f488201a415cad8cebb73180f56e.html

I’m not aware of any tools to do this sort of thing automatically. You will probably have to do the conversion by hand.