Packages in Python
Packages in Python
1
LAB EXERCISES
Data Manipulation – Loading and Filtration
PACKAGES IN PYTHON
2 Grouping and Merging data using Pandas
TABLE OF CONTENT
EXP NO DATE
1 Data Manipulation – Loading and Filtration
AIM:
To create a python – Pandas module to perform basic data manipulation tasks
using Jupyter Notebook
PROCEDURE:
Step – 1 : Install the required packages from Command Prompt using pip
Step – 2 : Launch Jupyter notebook from command Prompt
Step – 3 : Import necessary library files at the beginning of the module
Step – 4: Upload the ‘titanic’ dataset and import the same using pandas
Functions
Step – 5 : Perform the necessary programming
PROGRAM :
import pandas as pd
df=pd.read_csv('titanic.csv')
df
#MAKE 1ST COLUMN AS INDEX
df.set_index('Name')
#CHANGE THE 1ST, 2ND & 3RD COL NAME AND PRINT IT
c=df.rename(columns={ 'Ticket':'Ticket_No', 'Name':'Passenger_name'})
c
OUTPUT:
RESULT:
Thus, the python program to perform basic data manipulation tasks using
Jupyter Notebook was executed and output is verified successfull
EXP NO DATE
2 Grouping and Merging data using Pandas
AIM:
To create a python – Pandas module to perform different grouping and merging
operations using Jupyter Notebook
PROCEDURE:
Step – 1 : Install the required packages from Command Prompt using pip
Step – 2 : Launch Jupyter notebook from command Prompt
Step – 3 : Import necessary library files at the beginning of the module
Step – 4: Upload the ‘Online_Attendance’ , ‘covid_vaccine_statewise ‘ and
‘StatewiseTestingDetails’ datasets and import the same using pandas
Functions
Step – 5: Perform the necessary programming
PROGRAM:
#(i) Grouping
import pandas as pd
df=pd.read_csv("Online_Attendance.csv")
df
EXP NO DATE
3 Exploratory Data Analysis using Pandas
AIM:
To create a python – Pandas module to perform an Exploratory data analysis
using Jupyter Notebook
PROCEDURE:
Step – 1 : Install the required packages from Command Prompt using pip
Step – 2 : Launch Jupyter notebook from command Prompt
Step – 3 : Import necessary library files at the beginning of the module
Step – 4: Upload the ‘Loan Data’ datasets and import the same using pandas
Functions
Step – 5 : Perform the necessary programming
Program :
#Exploratory Data Analysis
import pandas as pd
df=pd.read_csv("Loan_Data.csv")
df
OUTPUT:
RESULT :
Thus, a python – Pandas module to perform an Exploratory data analysis using
Jupyter Notebook was created and output is verified successfully.
EXP NO DATE
4 Plotting Using Matplotlib -1
AIM:
To create a python – Pandas module to generate basic graphs in matplotlib
using Jupyter Notebook
PROCEDURE:
Step – 1 : Install the required packages from Command Prompt using pip
Step – 2 : Launch Jupyter notebook from command Prompt
Step – 3 : Import necessary library files at the beginning of the module
Step – 4: Upload the ‘C19INDIA’ datasets and import the same using pandas
Functions
Step – 5 : Perform the necessary programming
PROGRAM :
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#Loading the Dataset
df=pd.read_csv("C19INDIA.CSV")
df
df.head()
df.describe()
#Plotting
plt. figure (figsize=(20,25))
plt.plot(df1['CoviShield (Doses Administered)'],color='Blue',
linestyle='--', marker='o')
plt.xlabel("Days")
plt.ylabel("Vaccine Number")
plt.show()
OUTPUT:
RESULT:
Thus, a python – Pandas module to generate basic graphs in matplotlib using
Jupyter Notebook was executed and output is verified successfully
EXP NO DATE
5 Plotting Using Matplotlib -2
AIM:
To create a python – Pandas module to generate basic graphs in matplotlib
using Jupyter Notebook
PROCEDURE:
Step – 1 : Install the required packages from Command Prompt using pip
Step – 2 : Launch Jupyter notebook from command Prompt
Step – 3 : Import necessary library files at the beginning of the module
Step – 4 : Perform the necessary programming
PROGRAM:
#Importing
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.style
#Line Graph
x=[5,6,8,10,15]
y=[20,30,40,50,55]
plt.plot(x,y)
plt.title('STUDENT DATA-LINE GRAPH')
plt.ylabel('Present ')
plt.xlabel('Roll.no')
plt.show()
# BAR GRAPH:
studentnames = ['Jack','Daniel','Bira','Antiquity','Heineken']
marks = [850,1350,220,900,190]
plt.bar(studentnames,marks,color='purple')
plt.title('STUDENT DATA-BAR GRAPH VERTICAL')
plt.xlabel('NAMES')
plt.ylabel('MARKS')
plt.show()
# Histogram
student_marks=[45,12,13,26,15,55,100,98,95,54,58,56,52,24,71,6
6,66.5,12,23,55,78,10,9,5,10,22,35,65,45]
bins=[0,10,20,30,40,50,60,70,80,90,100]
plt.hist(student_marks,bins,rwidth=0.8,color='purple')
plt.xlabel('MARKS')
plt.ylabel('NUMBER OF STUDENT')
plt.title('STUDENT DATA-HISTOGTAM')
plt.show()
# SCATTER PLOT:
x=[5,6,8,10,15]
y=[20,30,40,50,55]
x2=[2,13,16,20,18]
y2=[25,35,16,23.5,40]
plt.scatter(x,y,color='red')
plt.scatter(x2,y2,color='black')
plt.title=('STUDENT DATA-SCATTER PLOT')
plt.ylabel('Present %')
plt.xlabel('Roll.no')
plt.show()
OUTPUT:
RESULT:
Thus, a python – Pandas module to generate basic graphs in matplotlib using
Jupyter Notebook was executed and output is verified successfully