Professional Documents
Culture Documents
Exploring Numpy and Pandas Library: Objective Lab Tasks: Code
Exploring Numpy and Pandas Library: Objective Lab Tasks: Code
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:
2. Import your excel file and perform any ten functions of Numpy and Pandas.
Code & Output:
“DataFrame & Indexing”
“Named Index”
“Excel File”
“Remove Duplicate”
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:
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
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:
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: