لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

Python Data Science What is Pandas?

Introduction to Pandas: Pandas is a Python library. It is used to analyze data.

Pandas is a Python library used for working with data sets. It has functions for analyzing, cleaning, exploring, and manipulating data.

The name "Pandas" was created by Wes McKinney in 2008 and it has a reference to both "Panel Data", and "Python Data Analysis".

Why Pandas?

1. Pandas helps to analyze big data and make conclusions based on statistical theories.

2. It can clean messy data sets, and and makes them readable and relevant.

Pandas provides answers to complex data questions like...

a. Is there a correlation between two or more columns?

b. What is average value?

c. What is Max value?

d. What is Min value?

What is data cleaning?

Pandas also deletes rows that are not relevant, or contains wrong values, like empty or NULL values. This is called cleaning the data.

Pandas source code is loated at this github repository. Installation of Pandas

If you have Python and PIP already installed on a system, then installation of Pandas is very easy.

Command to Install Pandas Install using the following command.

C:\Users\Your Name>pip install pandas

If this command fails, then use a python distribution that already has Pandas installed like, Anaconda, Spyder etc.

Import Pandas

Once Pandas is installed, import it in your applications by adding the import keyword as under.

import pandas

Now Pandas is imported and ready to use.

Example 1: The following is a list of vegetables ranked on the basis of every day use.

Code

import pandas as pd

mydataset = {

'Vegetables': ["Onion", "Ginger","Tomato", "Chillies", "Garlic"],

'Ranks': [1, 2, 3, 4, 5]

}

myvar = pd.DataFrame
(mydataset)

print(myvar)

the out put will be

Vegetables Ranks

0 Onion 1

1 Ginger 2

2 Tomato 3

3 Chillies 4

4 Garlic 5



Pandas as pd

Pandas is usually imported under the pd alias.

alias: In Python alias are an alternate name for referring to the same thing.

Create an alias with the as keyword while importing.

import pandas as pd

Now the Pandas package can be referred to as pd instead of pandas.

Example 2: A List of Fruits Ranked By Popularity.

Code

import pandas as pd

mydataset = {

'Fruits': ["Mangoes", "Apples","Bananas", "Grapes", "Oranges"],

'Popularity Ranks': [1, 2, 3, 4, 5]

} myvar = pd.DataFrame(mydataset)

print(myvar)

the output will be

Fruits Popularity Ranks

0 Mangoes 1

1 Apples 2

2 Bananas 3

3 Grapes 4

4 Oranges 5

Checking Pandas Version

The version string is stored under __version__ attribute.

Example 3

Code

import pandas as pd

print(pd.__version__)

the output will be

1.0.3

Note: This will differ depending upon what version is installed on your system.