Pandas In Python

Pandas library is used to read CSV and EXCEL files data. Using pandas we can do data processing and data manipulation.

It is a very important library, before we apply any machine learning algorithm we need analysis of data. This library helps us to make analysis the data.

Import the Pandas library using the below command,

import pandas as pd

Read CSV file using read_csv(‘path to CSV file’) like below,

df = pd.read_csv('Salaries.csv');

To check the data directly execute the below command and you will see the below data,

df.head()

Pandas in Python

head() gives us the first 5 rows from the dataset. Below is the command and output,

Pandas in Python

head(n) gives us the first n rows from the dataset. Below are the command and output.

Pandas in Python

tail() gives the last 5 rows from the dataset like below,

Pandas in Python

tail(n) gives us the last n rows from the dataset like below,

Pandas in Python

Get total salary paid to all employee in 2011,

Pandas in Python

Get Maximum salary paid to the employee in every year,

Pandas in Python

Get the employee's name who is drawing the highest salary in each year,

Pandas in Python

Get the top 5 salaries with employee name in each year,

Pandas in Python

To get selected columns from the dataset use the below command,

Pandas in Python

Get Employee details who are getting Minimum Salary from each year,

Pandas in Python

Info() gives every column with the number of non-null values and Data type of each column,

Pandas in Python

describe() gives us a count of rows in each column, mean, median, 25%, 50%,75% of each column,

Pandas in Python

loc () to get specific rows from the dataset, pass index number to retrieve.

Pandas in Python

Thank you!!!


Recommended Free Ebook
Similar Articles