A Beginner’s Guide to Python for Data Science - Part 2 Creating our first python project
In the last article, we introduced the software installation process required for data science in python.
In this blog, we will begin creating our first project in Pycharm.
We can open Pycharm and click on the plus sign to create a new project, as shown below:
The default project name is ‘untitled’, as shown in the image above.
Next, we see a small triangle shape symbol under the “Location” part of the screen. When we click the triangle, Pycharm provides us with many options, as shown below:
In the options above, we see one titled “New Environment Using”. If we click the drop-down menu, we see one of them is “Conda”, which is short for “Anaconda”. We need to select this option before clicking on the Create button to be sure that we are creating the new environment using anaconda distribution.
One important thing you should remember is that there cannot be any spaces in the environment name. Instead, you can separate the words by camel casing like “MyEnv”. The other option is to use an underscore like “My_Env”.
The purpose is to keep just one word for the complete name of the environment.
Now, we can hit the “Create” button at the end and let Pycharm do its magic to generate a shiny new environment.
When the environment is up and running, we can start our coding journey into the world of Python and data science.
The first step is to check if the environment is set up correctly, i.e., has the installation and creation process executed.
For the above check, we have to install the jupyter notebook and run a few commands.
So, to begin installing the jupyter notebook, do a simple Google search something like :
“conda install jupyter notebook”.
We should get a link from “Anaconda.org” in the results.
Select the one that says Jupyter under Anconda.org and open the link. We should reach the following site:
On the webpage, if we scroll down, we would get the required command highlighted in grey.
The command for installing is :
conda install -c anaconda jupyter
We need to run the command under the Terminal section of Pycharm. You will find the terminal section towards the bottom of the Pycharm UI, which got generated while creating the environment previously.
The above process works for installing any package in our environment.
For example, in the above image, we can see that I am installing the “Pandas” library in the terminal using the above-discussed method.
Once you paste the command and press enter, Python asks for your authorization to proceed with the installation.
All you have to do is press Y to install the desired package.
After the installation completes, the next step is to run the following command in the terminal:
jupyter notebook
As soon as you press enter after typing the above command, Python should spin up a webpage with the jupyter notebook setup as shown below:
Currently, my environment has some jupyter notebooks, so it is showing those, but when you do it for the first time, your jupyter notebook setup will be blank, i.e., no files will be present.
Now, click on the “New” button towards the right side of the screen and select the “ Python3 (ipykernal)” option to create your first jupyter notebook as shown below:
Now, as soon as we click the “Python3 ( ipykernal)”, we should see our notebook.
You should see the above page in your system if you have followed all steps correctly.
Now, the above-generated notebook is our playground, where we will learn the basics of the python language.
The first thing we will do is add two numbers and check the installation setup.
I am adding the numbers 1 and 5 for the test (you can choose any other number you like.). We get the correct output as shown below:
If you found this useful, you can check the below book and have a copy for yourself:
#Python #Data Science #Data Science Training #Learn Python
Comments
Post a Comment