Tutorial 2 QB & QP
Tutorial 2 QB & QP
(Autonomous)
PERUNDURAI ERODE-638 060
DEPARTMENT OF ARTIFICIAL INTELLIGENCE
1.
CO1 K3
Based on the code shown in the following screenshots, answer the questions that follow:
a) Use the output to answer what is the difference in behavior of .loc and .iloc when it comes
to slicing?
b) Without running, but just by looking at the data, what will be the output of
adult_df.loc['10002':'10005', 'education':'occupation']?
c) Without running, but just by looking at the data, what will be the output of
adult_df.iloc[1:4,3:5]?
d) Find the percentage value for” age” attribute using lambda function
e) Draw one histogram and bar chart for “occupation” attribute in the data
f) Calculate the count of each possibility happens in the “relationship” column
g) Group by marital status and sex and calculate the median of age.
2. Write a code using Boolean masking and calculate the mean of capitalGain for the individuals who have
education with more than 10 years and less than 10 years. Show the difference between the mean for
the same.
Names = ['Jevon', 'Dawn', 'Kayleigh', 'Jadene', 'Kennedy', 'Kaydee', 'Ansh', 'Flynn', 'Kier', 'Clarence'] CO1 K3
Math_grades = [80, 50, 60, 70, 60, 100, 70, 70, 60, 70]
Science_grades = [90, 80, 50, 50, 60, 50, 90, 70, 80, 80]
History_grades = [60, 90, 50, 90, 100, 100, 100, 100, 90, 70]
4. Identify the different types of data attributes available in the following dataset. Create a DataFrame
from the dataset and apply a boolean mask to filter rows where "Passed Exam" is "Yes"
CO1 K3
TUTORIAL – 2
Total Marks: 15
CO1 K3 8
a) Without running, but just by looking at the data, what will be the output of
adult_df.loc['10002':'10005', 'education':'occupation']?
b) Without running, but just by looking at the data, what will be the output of
adult_df.iloc[1:4,3:5]?
c) Find the percentage value for” age” attribute using lambda function
d) Draw one histogram and bar chart for “occupation” attribute in the data
SET-B
1. Given the grade data of 10 students, create a code using NumPy that calculates and reports their grade
average.
Names = ['Jevon', 'Dawn', 'Kayleigh', 'Jadene', 'Kennedy', 'Kaydee', 'Ansh', 'Flynn', 'Kier', 'Clarence'] CO1 K3 2
Math_grades = [80, 50, 60, 70, 60, 100, 70, 70, 60, 70]
Science_grades = [90, 80, 50, 50, 60, 50, 90, 70, 80, 80]
History_grades = [60, 90, 50, 90, 100, 100, 100, 100, 90, 70]
2.
Difference between melt and pivot method with example. CO1 K2 5
3.
CO1 K3 8
a) Without running, but just by looking at the data, what will be the output of
adult_df.loc['10001':'10003', 'race':'capitalGain']?
b) Without running, but just by looking at the data, what will be the output of
adult_df.iloc[0:2,1:3]?
c) Calculate the count of each possibility happens in the “relationship” column
d) Group by marital status and sex and calculate the median of age.