0% found this document useful (0 votes)
11 views4 pages

Tutorial 2 QB & QP

Uploaded by

hamsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Tutorial 2 QB & QP

Uploaded by

hamsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

KONGU ENGINEERING COLLEGE

(Autonomous)
PERUNDURAI ERODE-638 060
DEPARTMENT OF ARTIFICIAL INTELLIGENCE

Subject: 22ADC31 Data Processing and Visualization


Year and semester: II & III
Date: 22.08.2024
Topics: Unit -I: Numpy Core Modules – Pandas Core Modules
TUTORIAL – 2 QUESTION BANK
S.No Question COs BT
Level

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.

Age workclass education Education_num CaptialGain


39 State-gov Bachelors 13 2174
50 Self-emp-not-inc Bachelors 13 5013 CO1 K3
38 Private HS-grad 9 2407
53 Private 11th 7 0
28 Private Bachelors 13 5178
37 Private Masters 14 14084
th
49 Private 9 5 0
3. 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
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

5. Illustrate applying a function in Pandas with suitable examples.


CO1 K2
6. Outline the application of Boolean masking for filtering a DataFrame with examples.
CO1 K2
7. Explain multi-level indexing, melt and pivot using Pandas with suitable examples.
CO1 K2
8. 'Name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve']
'Age': [28, 24, 22, 29, 28]
'City': ['New York', 'Los Angeles', 'Chicago', 'Houston', 'New York']
CO1 K3
'Salary': [55000, 60000, 52000, 70000, 48000]
Create the above dataset as a Pandas DataFrame and perform iloc(), loc(), .unique(), at() and slicing
operations.

COURSE TEACHER ACADEMIC COORDINATOR


KONGU ENGINEERING COLLEGE
(Autonomous)
PERUNDURAI ERODE-638 060
DEPARTMENT OF ARTIFICIAL INTELLIGENCE

Subject: 22ADC31 Data Processing and Visualization


Year and semester: II & III
Date: 22.08.2024

TUTORIAL – 2
Total Marks: 15

S.No Questions CO(s) BT Mar


Mapp Lev ks
ed el
Set A
1. 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.

Age workclass education Education_num CaptialGain


39 State-gov Bachelors 13 2174
50 Self-emp-not-inc Bachelors 13 5013 CO1 K3 2
38 Private HS-grad 9 2407
53 Private 11th 7 0
28 Private Bachelors 13 5178
37 Private Masters 14 14084
49 Private 9th 5 0
2.
Difference between the types of multilevel indexing 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['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.

COURSE TEACHER ACADEMIC COORDINATOR

You might also like