You are on page 1of 12

Artificial Intelligence (SWE-314) SSUET/QR/114

LAB # 09
EXPLORING NUMPY AND PANDAS LIBRARY
OBJECTIVE
Exploring various functions of Numpy and Pandas library.

Lab Tasks:
1. Perform all the given functions of Numpy and Pandas then show the output.
Code:

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 1
Artificial Intelligence (SWE-314) SSUET/QR/114

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 2
Artificial Intelligence (SWE-314) SSUET/QR/114

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 3
Artificial Intelligence (SWE-314) SSUET/QR/114

2. Import your excel file and perform any ten functions of Numpy and Pandas.
Code & Output:
“DataFrame & Indexing”

“Named Index”

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 4
Artificial Intelligence (SWE-314) SSUET/QR/114

“Excel File”

“Remove Null Records”

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 5
Artificial Intelligence (SWE-314) SSUET/QR/114

“Replace Null Values”

“Replace Specific Column Null Values”

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 6
Artificial Intelligence (SWE-314) SSUET/QR/114

“Replace Using Mean”

“Remove Duplicate”

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 7
Artificial Intelligence (SWE-314) SSUET/QR/114

“Scatter Plot & Histogram”

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 8
Artificial Intelligence (SWE-314) SSUET/QR/114

LAB # 10
DATASET PREPROCESSING AND SCALING
TECHNIQUES
OBJECTIVE
Checking the data set for missing values and outliers. Implementing Normalization and
Standardization techniques to scale the values.

Lab Tasks:
1. Write a python code to fill all the null values in Gender column of employees.csv with “No
Gender”. Print the first 10 to 30 rows of the data frame for visualization.
Code:

Output:

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 9
Artificial Intelligence (SWE-314) SSUET/QR/114

2. Write a python code to scale the values of features (Age and Salary) using Min-Max
Normalization technique. Verify your answers by applying the formula mentioned above.
Code:
import pandas as pd
import numpy as np
from sklearn import preprocessing

Output:

Verification:

X= =0 X= =0

X= = 0.84615385 X= = 0.88888889

X= = 0.38461538 X= = 0.33333333

X= = 0.15384615 X= = 0.11111111

X= =1 X= =1

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 10
Artificial Intelligence (SWE-314) SSUET/QR/114

3. Write a python code to scale the values of features (Age and Salary) using Standardization
technique. Verify your answers by applying the formula mentioned above.
Code:
import pandas as pd
import numpy as np
from sklearn import preprocessing

Verification:

.
X= = -1.23116128 X= = -1.14906888
.
.
X= = 0.95316176 X= = 1.03963374
.
.
X= = -0.23829044 X= = -0.32830539
.
.
X= = -0.83401654 X= = -0.87548105
.
.
X= = 1.3503125 X= = 1.31322157
.

Output:

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 11
Artificial Intelligence (SWE-314) SSUET/QR/114

4. Given this dictionary, create a dataframe from dictionary and interpolate the missing
values using backward interpolation. Hint: use interpolate().
dict = {'First Score': [100, 90, np.nan, 95],
'Second Score': [30, 45, 56, np.nan],
'Third Score': [np.nan, 40, 80, 98]}
Code:
import pandas as pd
import numpy as np
from sklearn import preprocessing

Output:

Name: Muhammad Rameez


Roll No: 2019-SE-213
Section: E Page | 12

You might also like