While it would be fairly easy to translate these examples into Python with the right libraries, I would rather focus on ...
Reticulate is a handy way to combine Python and R code. From the reticulate help page suggests that reticulate allows for: "Calling Python from R in a variety of ways including R Markdown, sourcing ...