Getting started with Pandas

Now that you have got a little bit of introduction to Pandas, it’s time to get started with Pandas. We are going to start from Installation, and are just assuming that you already have got Python installed in your system. The installation part is very easy, but we will go through it so that we can smoothly move ahead.

Getting started with Pandas

How to Install Pandas?

We are mostly talking about Pandas in this tutorial series, but if you are heading toward Machine Learning and Data Science, then you might want to use other tools like Google Colab, or Anaconda(or Miniconda). We will go through some different techniques you can get started using Pandas.

Using Pip

First of all, if you already have Python installed on your system, then you can simply use pip, to install pandas into your system. Follow the below steps to install pandas into your system, using pip.

  • First, open your terminal/command prompt.
  • On your Command prompt, just write the following command – pip install pandas

Don’t forget to hit enter after that. You will find that the pandas will get installed. After that, you can start using Pandas in your Python programs. Later on, we will see how, but we need to see other ways to start using Pandas.

Using Google Colab

If you are moving towards Machine Learning or Data Science, you must be familiar with the tool called Google Colab. Google Colab allows anyone to write and execute Python code using the browser. It is especially used in Machine Learning and Data Analysis. To use Pandas on Google Colab is as easy as typing. Well, you don’t need an installation. Just import pandas and start using them.

Using Anaconda

It’s less likely that you are familiar with Machine Learning and Data Science, but not with a great tool like Anaconda. Anaconda is the most popular data science platform. By downloading Anaconda into your system, you can then launch Jupyter Lab, wherein you can write and execute your Python codes. You can there import pandas, and then start using it.

How to import pandas?

Well, you might have got started with pandas either way, but I have been emphasizing the point that you would need to import pandas. But the next question is how do you import pandas? It’s too easy. You just need to use the import statement in Python. Here is how you do it.

import pandas as PD

Well, you might be familiar with this alias thing in Python imports, where we give some aliases for the package. For example, here pandas are given the alias pd, which means that in the program, we will be using pd instead of pandas (consider this like a nickname for pandas for this program). It is not compulsory, but rather a convenience, so that you don’t need to write pandas every time.

Also, giving an alias as PD is not compulsory. You may give something else, like import pandas as pan, but you would see the PD thing as used by literally many.

After you are done installing pandas into your system anyways, you can check the version. To do this, you just need to use the below code.

import pandas as pd
print(pd.__version__)

Here is a sample program in Python, where we are implementing pandas. Don’t even worry about what’s written in the program, but just take a brief look at it, since we are going to explain it later –

import pandas as pd

df = pd.DataFrame({
"Branch": ["CSE", "EEE", "IT", "Mechanical"],
"Number of students placed": [25, 16, 34, 32]
})

df

Don’t worry about what the above code is doing, because all we are doing is creating a DataFrame, which, we are going to explore later, but you can try to copy this code and run it by yourself in the Google Colab, and see the DataFrame. You should see it like an Excel table.

So, we have successfully installed and imported Pandas. Now, it’s time to move towards further concepts and understand more about pandas.