How To Lose Weight Running

Running is a great form of exercise for those looking to lose weight and get in shape. It’s a low-impact activity that burns a lot of calories and can be done anywhere, at any time. Whether you’re a…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Troubles I had when switching from R to Python and which way worked for me

I started my data science journey with R. It has been the language that sparked my enthusiasm for programming and data science and that’s why I’ve always positioned myself as an R advocate in the battle between Python and R. However, while I advanced as a data scientist, I eventually reached the point where R has no longer been the best possible option for me (e.g. when it comes to deep learning). At that point, I decided to break new ground and to discover what the opponent has to offer…

Although I have by now learned to appreciate the benefits of Python, my start was still rather bumpy. Even before I could enter and run code, I had to realize that there are some differences between both languages when it comes to the installation and setup you need to be aware of. As I spent quite some time looking for an easy(!) to understand installation guide and figuring out how to properly get started with Python, I’d like to spare you some confusion. So here are the first three hurdles I needed to take and what my learnings were.

An Integrated Development Environment (IDE) is a tool which helps you write, test, and debug code. For R, R-Studio is THE most populat IDE. I’ve rarely seen R code run in another IDE. For Python, however, the situation is somewhat different. While searching for the (to me) most suitable IDE, I stumbled across names like Spyder, PyCharm, Jupyter Notebook or even Anaconda (which is not an IDE, but I will come to this in a second) not knowing how they differ or how they relate to each other. Let me therefore shed some light into the dark:

Spyder, PyCharm, and Jupyter Notebook all belong to the most popular IDEs for Python and no matter for which one you decide, it won’t be a bad choice. Still, although Jupyter Notebook is often recommended as an easy-to-use tool for Python beginners, I had my problems with it as its structure differs somewhat from R-Studio, e.g. there is no built-in variable explorer. So I went with Sypder (and I’ve done so well with it that I didn’t even had to try PyCharm or another IDE yet).

The great thing about Spyder is also that it is part of the Anaconda distribution. That means that Anaconda provides you with everything you need for data science in Python “out-of-the-box”. Besides Spyder, it also includes the core Python language and comes with more than 100 pre-installed packages. In addition, Anaconda is a great package and dependency manager.

Left: Anaconda Home Screen, Right: Spyder
Open terminal app from Anaconda

So far, so good! What really frustrated me when figuring out how and especially where to install Python packages, however, was that in Q&A forums or on GitHub, people did not only reported to use pip install, but als pip2 install or pip3 install for installing packages. Therefore, I ended up being very confused about how the commands differ and which command to use when. Also, as a beginner it is very hard to understand the (often veeeery geeky) explanations you can find online. Now, having a greater understanding of Python and how it works, it’s not that complicated anymore. So, let me try to explain in easy words to save you from the trouble:

pip install is the “standard” command to install new Python packages. Additionally, you might need pip2 install or pip3 install in case you have different Python versions installed on your computer and you’d like to refer to them separately. So if you have for example Python 2.7 installed, you would use pip2 install for adding further packages to this version. By contrast, for Python 3 you would use pip3 install.

Still sounds complicated? No worries! Another great thing about Anaconda is that we do not need to care about whether to use pip2 or pip3 when opening the terminal app the way I explained above. Anaconda automatically makes sure that we are installing our required package for the Python version we are currently working with by simply typing in pip install.
(In case you still want to find out which version you are currently using, just type python --version in the terminal and it will immediately tell you. I am for example currently using Python 3.8.8. I could therefore also type in pip3 install when installing a package to the Python version I am currently working with.)

Look up Python version

So, let me sum up my third learning: When switching from R to Python, load functions by referring to the package AND the function itself.

Which problems did you face when switching from R to Python?

Add a comment

Related posts:

Spiritual transformation through love in Little Women

An updated version of one of the podcast episodes. Louisa May Alcott has a special narrative that she repeats in many of her novels. It´s a common motif, especially in Little Women. The idea is that…

Always Ask a Narcissist This One Question

A couple of days ago, I was approached by a guy I semi-know from an open mic I attended back in 2019. He had been showing interest in me, despite me not reciprocating the energy at all. He was…

Life Is Wrapped in Mystery

Why does life live in this world? Why does life come to this world? Why does life go from this world? Life is wrapped in mystery. If the mystery is solved, spirits will reveal themselves.